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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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)

 


Follow on LinkedIn
@ 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors