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
Alaguarta
Regular Visitor

Case Statement to PBI DAX

I am needing help writing my DAX statement to a PBI friendly formula for a query. 

 

Calc_Analyze_Behavior:

Case  when

sum(

 Case  when [pq01_score] is null then 0 else [pq01_score] end,

 Case  when [pq02_score] is null then 0 else [pq02_score] end,

 Case  when [pq03_score] is null then 0 else [pq03_score] end)

  =3 then 1 else 0 end

 

I tried to use SWITCH but it wasn't working well for me. Any help is much appreciated 🙂 

4 REPLIES 4
Anonymous
Not applicable

Analyze_Behavior =
	var __score1 = sum( 'ADAPT Data'[pq01_score] )
	var __score2 = sum( 'ADAPT Data'[pq02_score] )
	var __score3 = sum( 'ADAPT Data'[pq03_score] )
	var __sum = __score1 + __score2 + __score3
	return
		( __sum = 3 ) * 1

 

Best

D

Anonymous
Not applicable

You can also do it in Power Query Editor instead of DAX. Add conditional collumn and set rules to use certain columns and/or values as outputs

12345.png

Greg_Deckler
Super User
Super User

That seems overly complex

 

Calc_Analyzer_Behavior =
 IF([pq01_score] + [pq02_score] + [pq3_score] = 3,1,0)

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hey Greg! Thanks so much for your help! 

 

I have this right now because I need to calculate all these 3 scores based on a unique eval ID however I am getting an error...
 
Analyze_Behavior = CALCULATE(IF(SUM(('ADAPT Data'[pq01_score] + 'ADAPT Data'[pq02_score] + 'ADAPT Data'[pq03_score]) = 3),1,0), 'ADAPT Data'[eval_id])
 
Any thoughts on what I can do? 

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.