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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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