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
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/LIKE!
PROUD TO BE A SUPER USER!
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/LIKE!
PROUD TO BE A SUPER USER!
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
Super User
Super User

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/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

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.

Top Solution Authors