Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

convert multiple case statements in sql to dax

Hi Everyone,

 

Im in need of help converting the below case statements to dax. 

 

Case

WHEN ([SCODE]) = 47123

THEN((([Total Actual]+1350)+Case when isnull([Total Budget_Food]) then (-1*[Total Budget]) else [Total Budget_Food] END)/[Total ComparedOcc_FB]*[Max Negation])/((Case when isnull([Total Budget_Food]) then (-1*[Total Budget]) else [Total Budget_Food] END)/[Total Compared_Occ_FB])

ELSE(([Total Actual]+Case when isnull([Total Budget_Food]) then (-1*[Total Budget]) else [Total Budget_Food] END)/[Total Compared_Occ_FB]*[Max Negation])/((Case when isnull([Total Budget_Food]) then (-1*[Total Budget]) else [Total Budget_Food] END)/[Total Compared_Occ_FB])

END

Your assistance will be much appreciated.

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You can use Switch with True

example

Switch(True() ,

[SCODE]) = 47123 , [Total Actual]+1350 ,

isblank([Total Budget_Food]) , -1*[Total Budget],

divide([Total Budget_Food] END), [Total ComparedOcc_FB]*[Max Negation])

)

 

 

same way you can add another switch  true

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , You can use Switch with True

example

Switch(True() ,

[SCODE]) = 47123 , [Total Actual]+1350 ,

isblank([Total Budget_Food]) , -1*[Total Budget],

divide([Total Budget_Food] END), [Total ComparedOcc_FB]*[Max Negation])

)

 

 

same way you can add another switch  true

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.