cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vedhikha
Regular Visitor

How to use the DAX variable s in the measure below in another measure?

The below DAX returns both "ontime " and "delayed" when pulled into a donut chart. I want to write a DAX that only pulls the "ontime" in the donut chart.
vedhikha_0-1680291112146.png

 

 
Status measure =
VAR s = CALCULATE(COUNTX(FILTER(SUMMARIZE(OnTimePerformance,OnTimePerformance[carr_desc],OnTimePerformance[LD_LEG_ID],OnTimePerformance[actual_departure_deviation],OnTimePerformance[SRA_NUMBER],OnTimePerformance[APPOINTMENT DELIVERY WINDOW],OnTimePerformance[actual_dlvy],OnTimePerformance[LANE],"Status",[Dly_Variance]),[Status]="Ontime"),[Status]), USERELATIONSHIP(CalendarTable[Datekey],OnTimePerformance[actual_dlvy_key]), USERELATIONSHIP(Carrier[SCAC],OnTimePerformance[CARR_CD]))
VAR s1 = CALCULATE(COUNTX(FILTER(SUMMARIZE(OnTimePerformance,OnTimePerformance[carr_desc],OnTimePerformance[LD_LEG_ID],OnTimePerformance[actual_departure_deviation],OnTimePerformance[SRA_NUMBER],OnTimePerformance[APPOINTMENT DELIVERY WINDOW],OnTimePerformance[actual_dlvy],OnTimePerformance[LANE],"Status",[Dly_Variance]),[Status]="Delayed"),[Status]), USERELATIONSHIP(CalendarTable[Datekey],OnTimePerformance[actual_dlvy_key]),USERELATIONSHIP(Carrier[SCAC],OnTimePerformance[CARR_CD]))
Return SWITCH(SELECTEDVALUE('Status'[Status]),"Ontime",s,s1)
 
 
2 ACCEPTED SOLUTIONS
vedhikha
Regular Visitor

@olgad Yes. I want just 77.52.

Measure 3 = Calculate(DIVIDE(MAXX(ALLSELECTED('Status'[Status]),'Status'[Status measure]), CALCULATE('Status'[Status measure],ALL('Status'[Status]))), 'Status'[Status]="Ontime")
 
When I do this, I get 3.45. 

View solution in original post

Dont place it on the pie chart, it doesnt male sense to use a pie chart showing only one ontime. Make a card with the % theb the value shall be correct. Or how do you imagine it to look?


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

View solution in original post

5 REPLIES 5
vedhikha
Regular Visitor

@olgad Yes. I want just 77.52.

Measure 3 = Calculate(DIVIDE(MAXX(ALLSELECTED('Status'[Status]),'Status'[Status measure]), CALCULATE('Status'[Status measure],ALL('Status'[Status]))), 'Status'[Status]="Ontime")
 
When I do this, I get 3.45. 

Dont place it on the pie chart, it doesnt male sense to use a pie chart showing only one ontime. Make a card with the % theb the value shall be correct. Or how do you imagine it to look?


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

@olgad : I used the measure and placed it as a card within my donut chart. Thank you so much, this just gives me the Ontime %

 

vedhikha_0-1680540807256.png

 

vedhikha_0-1680524117383.png

 

olgad
Memorable Member
Memorable Member

Hi,

do you want to show only ontime-77.52?
%=
Calculate(DIVIDE(MAXX(ALLSELECTED(Table[Status]),[YOUR MEASURE]), CALCULATE([YOUR MEASURE],ALL(Table[Status]))
), Table[Status]="Ontime")
example how it will look like
olgad_0-1680359310399.png

 




DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors
Top Kudoed Authors