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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors