Virtual Columns - Only sync when in a certain view.

Does anyone know a workaround for using an expression such as IF(Context("View")="xyz" in a virtual column formula, so that the virtual column will only load when looking at the view it is needed for?  It would help my app a ton if certain virtual columns could just load when needed rather than on every sync. 

There is a warning from appsheet that context view or viewtype may not work correctly if used on a VC. Just curious if anyone has found a workaround for the issue. I also tried IF(Context("Table") = "xyz", but it didn't seem to do anything. 

Thanks!

0 4 218
4 REPLIES 4

You might try:

  • Show columns - to display information
  • Increasing the reference web density of your app, allowing for more complex and deeper chaining dereferences (this way you can use a chaining dereference formula to get your value, vs. building it inside a VC.
  • Using slices to hold data subsets

 

Steve
Platinum 5
Platinum 5

We might be able to offer concrete suggestions if you share the App formula expression of one or two of the virtual columns you're concerned about.


@S-Sand wrote:

an expression such as IF(Context("View")="xyz" in a virtual column formula, so that the virtual column will only load when looking at the view it is needed for?


No that's not possible. Because virtual columns get calculated only during a sync. 

The only thing what you can do is to use or the UserSettings where the user enables or disables some heavy calculations. 

Then in the Virtual column's App formula you can write:
IFS(USERSETTINGS("Do you want the Virtual Column XYZ to be calculated")=true, Your_Expression)

After saving the UserSettings, AppSheet will do a sync and the Virtual Columns will be calculated. Or not calculated if set to false.

Instead of trying to base the formula on Context("ViewType"):

  • Try basing it on a column.

Include a column that's an enum with a single option, visible only inside the form, that's only valid if the field is blank; this will create a "button" inside the form that your user can click, and you can use this for your condition for the heavy formula. 

 

IFS(IsNotBlank([new_enum_button]), 
  __YOUR_HEAVY_FORMULA_HERE
)

 

With the validation that the field be blank, a user can't save with the toggle turned on - thus reserving the heavy formula for inside the form.

------------------------------------------------------------------------------------------------------------------

If you're using Google Sheets or Excel:

  • Here's some note parameters for the column:

AppSheet:{"IsRequired":false,"Type":"Enum","Default":"","TypeAuxData":"{\"EnumValues\":[\"Show Details\"],\"AllowOtherValues\":false,\"EnumInputMode\":\"Buttons\",\"Show_If\":\"CONTEXT(\\\"ViewType\\\")=\\\"Form\\\"\",\"Valid_If\":\"ISBLANK([_this])\",\"Error_Message_If_Invalid\":\"Please clear the button before saving.\"}","Description":" "}

Put that in the header of the column as a note before you regenerate your columns and you won't have to do the configuration yourself.

Top Labels in this Space