Simplify Format Rules expressions to improve performance

behavior
(David Joyce) #1

It has been suggested to me (by the performance analyzer) that there could be a potential improvement in sync times, because of Format Rules expressions on a table.

Does anyone have any suggestions how I could improve these expressions?
Security filters are already in place.

Expression 1.
AND(
[AssignedTo]=UserSettings(UserID),
ISNOTBLANK([AssignedDate]),
HOUR(TODAY() - MAX( LIST([LastUpdated], [AssignedDate]) ) ) / 24 >
LOOKUP(“Address Fields”, “AppSettings”, “SettingName”, “Numeric_”)
)

Expression 2.
AND( [AssignedTo] = UserSettings(UserID),
HOUR(TODAY() - MAX(LIST( [LastUpdated], [AssignedDate] )) ) / 24 <=
LOOKUP(“Address Fields”, “AppSettings”, “SettingName”, “Numeric_”)
)

Expression 3.
AND(
OR(ISBLANK([AssignedTo]),
AND(ISNOTBLANK([AssignedTo]), UserSettings(UserID)<>[AssignedTo])),
HOUR(TODAY() - MAX( LIST([LastUpdated], [AssignedDate]) ) ) / 24 >
LOOKUP(“Address Fields”, “AppSettings”, “SettingName”, “Numeric_”)
)

Any tips gratefully accepted

1 Like
(Levent Kulacoglu) #2

@David_Joyce
Setup a VC in your table with this expression:

AND(
[AssignedTo]=UserSettings(UserID),
HOUR(TODAY() - MAX( LIST([LastUpdated], [AssignedDate]) ) ) / 24 > LOOKUP(“Address Fields”, “AppSettings”, “SettingName”, “Numeric_”)
)

Then you can evalueate:
Expression 1:
AND(
ISNOTBLANK([AssignedDate]),
[VirtualColumnName]=TRUE
)

Expression2:
[VirtualColumnName]=TRUE

(David Joyce) #3

Hmm. Ok, thank you very much. That would simplify the expression certainly, but AppSheet tells us that virtual columns also have a performance cost. I will try it and see what effect it has, thanks again

(Levent Kulacoglu) #4

@David_Joyce
Using complex expressions in Format rule conditions are always much more expensive than using them in Virtual columns :wink:

2 Likes
(David Joyce) #5

Hmm, Thats a nice little nugget of information, which I did not know. My thanks, once again, sir!

(Levent Kulacoglu) #6

You’re welcome @David_Joyce, my pleasure. Glad to be helped of.