Forum Discussion
DAX formula
Anonymous , Hoping region part of the same table
CALCULATE(SUMX('Inv. Opportunities'
Switch( True() ,
[Region] ="EMEA" ,[Excess Stock Value]/9.1,
[Region] ="APAC" ,[Excess Stock Value]/9.1, // change as per need
[Excess Stock Value]
))
6 Replies
- amitchandak
Super User
Anonymous , Hoping region part of the same table
CALCULATE(SUMX('Inv. Opportunities'
Switch( True() ,
[Region] ="EMEA" ,[Excess Stock Value]/9.1,
[Region] ="APAC" ,[Excess Stock Value]/9.1, // change as per need
[Excess Stock Value]
))
- AnonymousNot applicable
Thank you amitchandak!
I applied the formula, but I got the following error.
Excess Buffered Stock = CALCULATE(SUMX('Inv. Opportunities'Switch( True(),Location[Region] ="EMEA" ,'Inv. Opportunities'[Excess Stock Value]/9.1,Location[Region] ="APAC" ,'Inv. Opportunities'[Excess Stock Value]/9.1,'Inv. Opportunities'[Excess Stock Value]))The syntax for 'Switch' is incorrect. (DAX(CALCULATE(SUMX('Inv. Opportunities'Switch( True(),Location[Region] ="EMEA" ,'Inv. Opportunities'[Excess Stock Value]/9.1,Location[Region] ="APAC" ,'Inv. Opportunities'[Excess Stock Value]/9.1,'Inv. Opportunities'[Excess Stock Value])))).
I tried the applying what is told in the error, it still shows error.
- Samarth_18
Community Champion
Hi Anonymous ,
You have missed some comma's and closing brackets in your formula. Below code would be ideal code which Amit suggested:-
Excess Buffered Stock = CALCULATE ( SUMX ( 'Inv. Opportunities', SWITCH ( TRUE (), Location[Region] = "EMEA", 'Inv. Opportunities'[Excess Stock Value] / 9.1, Location[Region] = "APAC", 'Inv. Opportunities'[Excess Stock Value] / 9.1, 'Inv. Opportunities'[Excess Stock Value] ) ) )Thank you,
Samarth
- AnonymousNot applicable
Thanks a lot! Samarth_18 !
Can I also know how to apply the same if there is a condition?
For eg:
Non-Buffered Stock = CALCULATE(SUM('Inv. Opportunities'[On Hand Value]),'Inv. Opportunities'[InventoryPlanning]="NB")How to apply the same for the formula above?Thank you for your help!