Hello AppSheet Community,
MAX() and SWITCH() functions in Google Docs templates, used by an AppSheet automation bot. My template works perfectly with LOOKUP() and basic arithmetic, but introducing MAX() and SWITCH() functions makes the template preview go completely blank in the relevant sections.
What's Working (for months):
My template correctly displays values from LOOKUP() and subtractions, e.g.:
<<NUMBER(LOOKUP("Go03","StoreGoals","Tienda","Upgrades Goal")) - NUMBER(LOOKUP("Go03","StoreGoals","Tienda","Total Upgrade Sales"))>>
This produces results like 10, 0, or even -2 (which I want to fix).
What Fails (Causes Blank Preview):
When I try to use MAX() to prevent negative numbers, the preview goes blank:
<<MAX( (NUMBER(LOOKUP("Go03","StoreGoals","Tienda","Upgrades Goal")) - NUMBER(LOOKUP("Go03","StoreGoals","Tienda","Total Upgrade Sales"))) ,0)>>
Similarly, SWITCH() also causes blank previews (like when you forget to add a '>>' ).
Troubleshooting Done:
Data Types: Confirmed all LOOKUP results are converted to NUMBER().
Blanks Handled: Used IFBLANK(..., 0) to ensure numerical inputs, still blank.
Simple Test: Even <<MAX(-5, 0)>> in the template yields a blank, suggesting the function itself isn't evaluating in the template preview.
Data Validity: Underlying StoreGoals data is confirmed numeric and accurate.
My Conclusion:
Since simple arithmetic works, but core functions like MAX() and SWITCH() cause blank previews even with guaranteed numeric inputs, I suspect a bug in the AppSheet Google Docs template rendering engine's handling of these specific functions.
Solved! Go to Solution.
You're using MAX() wrong. It requires a single List type as an argument.
<MAX(LIST(-5, 0))>> instead of<MAX(-5, 0)>>
I imagine you're probably using SWITCH() wrong as well, but you haven't shown how you're using it.