I’m trying to create a macro calculator based on TDEE in the Formula Editor, but I’m running into issues with the syntax and limitations of the editor. Here’s what I want to achieve:
I have a dropdown called “Makro Fordeling” with different diet options (Balanced, High-Protein, etc.).
Based on the selected diet, I want to calculate grams of protein, carbs, and fat from the TDEE.
For example:
Balanced: 30% protein, 40% carbs, 30% fat
High-Protein: 45% protein, 25% carbs, 30% fat
I initially tried using nested IF statements like in Excel:
IF(Makro Fordeling=1, (TDEE0.30)/4,
IF(Makro Fordeling=2, (TDEE0.45)/4, 0))
…but the editor shows “invalid formula”.
From my testing, it seems this Formula Editor only supports one IF per line, like this:
IF(Makro Fordeling, 1, 1)((TDEE*0.30)/4)
…but then I can’t combine multiple diet options in one formula. Each diet would require a separate calculation, which is not ideal, because I want one calculation that automatically adjusts protein, carbs, and fat based on the selected diet.
My questions:
Is it possible to create a multi-choice macro calculator in this Formula Editor that selects different macro percentages from one dropdown?
If yes, what is the correct syntax to do this?
If not, are there any workarounds to achieve this behavior?
I would really appreciate any guidance or examples if anyone has successfully implemented something similar.
You’d like to count fats, protein and carbs based on the option chosen in the Makro Fordeling dropdown, right?
If so, you don’t need to use the IF function. Just add the Makro Fordeling field name to the calculation and the widget will automatically pull the value of the chosen option:
Yes, what you are saying is technically correct in one very limited scenario, but it won’t do what you want. Let me clarify:
What you are saying works only if each dropdown option has a single numeric value, e.g., the actual number of grams of protein. Then I could have just reference the dropdown directly.
The problem in my case:
Each diet has three separate values (protein, carbs, fat).
The dropdown only stores one value per option.
So simply referencing the dropdown cannot calculate all three macros, because it doesn’t know the percentages for the other two macros.
BUT I think I found an solution, it just means a bit more work.
I can use conditional Logic, and make it work that way actually.
Yep, in this case, the conditional logic for the calculations is just what you need. I see you’ve already set it up and everything seems to be working fine.