Dear nice people,
I used to have a lot of virtual columns in almost 20 tables in my app, but thankfully after reading your performance-related topics in this forums I went back to convert them to normal columns when possible. The dataset is still small so I didn’t notice any performance issues, but I’m glad to have been able to avoid future problems thanks to your advice and patience especially @Steve in this regard.
I need to ask you please regarding one particular case that I would have to do repeatedly and would like to know if my approach is appropriate or there is a better way.
An example involving three tables:
- Contracts, it has a Deposit amount paid by the Customer during the life of a Contract.
- Movements, marks the start and end of a particular Contract.
- Transactions, records payments and reimbursements of Deposits.
They are related as follows:
- A Transaction column in “Movements” table has a reference to “Transactions” table to record a Deposit paid by the Customer at the start of a “Contract” (which as another column with reference to Contracts table).
- A new Movement form creates a record at the end of the same Contract, retrieves the first Deposit Transaction and shows it to the app user, for him to know the amount of Deposit the customer had paid, then ask the user whether to retain the Deposit or create a new Transaction to reimburse it.
I used to have a virtual column named “oldTransaction”, type List, base Ref, with the following formula:
IF( "End" = [movementType],
SELECT( Movements[transactionID],
AND(
[contractID] = [_THISROW].[contractID],
"Start" = [movementType]
)
),
LIST()
)
This worked perfectly and the form for the End Movement showed a nice, clickable inline view of the first Deposit transaction, and the user could not only see the old amount but also open the old transaction from within the form and see it’s details, like date, hour, ID etc, then close it and come back to the form to complete the End Movement.
When I realized after, that this is bad practice because the value of the virtual column will never change but each app sync will recalculate the column for all Movements rows of all Contracts again and again. So I decided to turn this virtual column to a normal column.
I was faced with the following problems:
- You cannot have List Type with a normal column. It has to be virtual.
- Turning the column type to Ref and adapting the formula accordingly, made me lose the inline view in the form, and the user is now presented only with a greyed number showing the amount of of the first transaction.
What I did was to create a new virtual column “virtualOldTransaction”, type List base Ref with the following formula:
LIST([oldTransaction])
and I have my inline view back. I thought this at least would let me avoid a SELECT in a virtual column.
What do you think please? Should I continue doing this (I’ll have to do it around 30 times)? is it worth it? Anything better?
Thanks much!