Thank you Guy for the “Variables” tutorial link. I gave it a try and came up with 2 variations. In my scenario, I want to know which among the 3 formula variations is more efficient and why.
- Original formula without variables (see in previous reply)
- Using Variables, variation#1
- Using Variables, variation#2
Using Variables Variation#1:
Total Expense Version 1 =
VAR _CC_Version =
CALCULATE([Total Value]/SELECTEDVALUE('Constant INR'[Rate],70),FILTER(Expense,Expense[Entity]="20"),FILTER(Expense,Expense[Version]="Constant Currency"))
+CALCULATE([Total Value]/SELECTEDVALUE('Constant GBP'[Rate],.75),FILTER(Expense,Expense[Entity]="40"),FILTER(Expense,Expense[Version]="Constant Currency"))
+CALCULATE([Total Value],FILTER(Expense,Expense[Entity]<>"20"),FILTER(Expense,Expense[Entity]<>"40"),FILTER(Expense,Expense[Version]="Constant Currency"))
`VAR _Non_CC_Version = CALCULATE([Total Value],FILTER(Expense,Expense[Version]=SELECTEDVALUE('Version1'[Version])))`
RETURN
IF(SELECTEDVALUE('Version1'[Version])="Constant Currency"
,_CC_Version
,_Non_CC_Version)
Using Variables Variation#2:
Total Expense Version 1 =
VAR _India = CALCULATE([Total Value]/SELECTEDVALUE('Constant INR'[Rate],70),FILTER(Expense,Expense[Entity]="20"),FILTER(Expense,Expense[Version]="Constant Currency"))
VAR _UK = CALCULATE([Total Value]/SELECTEDVALUE('Constant GBP'[Rate],.75),FILTER(Expense,Expense[Entity]="40"),FILTER(Expense,Expense[Version]="Constant Currency"))
VAR _Other_Entities = CALCULATE([Total Value],FILTER(Expense,Expense[Entity]<>"20"),FILTER(Expense,Expense[Entity]<>"40"),FILTER(Expense,Expense[Version]="Constant Currency"))
VAR _CC_Version = _India + _UK + _Other_Entities
VAR _Non_CC_Version = CALCULATE([Total Value],FILTER(Expense,Expense[Version]=SELECTEDVALUE('Version1'[Version])))
RETURN
IF(SELECTEDVALUE('Version1'[Version])="Constant Currency"
,_CC_Version
,_Non_CC_Version)
Best regards,
Ferdinand