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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors