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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

calculating the median of a measure

I have a visual that looks like this 

Customer IDaverage order valuemedian (should be)
016764
021764
032364
045564
059064

average order value is a measure

 

average order value = sum(order[sales])/distinctcount(order[order ID])

 

How can I calculate the median of the average median value.

I tried the following measure but it returned a different median (52)

 

median = MEDIANX(order, CALCULATE(SUM(order[sale])/DISTINCTCOUNT(order[order ID]),ALL(order)))

 

 

Thanks in advance!

1 ACCEPTED SOLUTION

@Anonymous 

Give this a try.

median = CALCULATE ( MEDIANX ( ALL ( 'order'[order ID] ), [average order value] ), REMOVEFILTERS ( 'order'[Customer] ) )

View solution in original post

5 REPLIES 5
jdbuchanan71
Super User
Super User

Multiple lines on the same order may be causing the problem.  Give this a try.

median = MEDIANX ( ALL ( 'order'[order ID] ), [average order value] )
Anonymous
Not applicable

Hi ,thanks for your solution, it got me very close.

But I got the following result.

Customer ID  average order value  median  
0167 
0217 
0323 
0455 
0590 
total61.562

 

Any idea how it can return the same number in each row instead just in the total. Because I am going to need it for a following calculation.

@Anonymous 

Give this a try.

median = CALCULATE ( MEDIANX ( ALL ( 'order'[order ID] ), [average order value] ), REMOVEFILTERS ( 'order'[Customer] ) )
amitchandak
Super User
Super User

@Anonymous , Try like

 

calculate( MEDIAN(order[sales]) , ALL(order))

 

or

 

calculate( Average(order[sales]) , ALL(order))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi thank you for the response.

 

I think your solution gives the median value of all of the orders.

 

I'm trying to get the median value of the average order value of all customers. Could you elaborate based on your solution please?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors