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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

MEDIANX returns incomplete data compare to AVERAGEX

Hi Guys, I have this measure:

 

CalcuateData = 
var calcType = SELECTEDVALUE('Calculate By'[ComputeBy])
RETURN
SWITCH(
    TRUE(),
    calcType = "Average", AVERAGEX(VALUES(car[ExtractedDate].[Date]), CALCULATE(SUM(car[Cnt]))),
    MEDIANX(VALUES(car[ExtractedDate].[Date]),CALCULATE(SUM(car[Cnt])))
)

 

For the average, I got the result:

Daniel_Pel_0-1637580043094.png

but for the median:

Daniel_Pel_1-1637580072868.png

I only have two months. It seems like the month should be finished before having the value for median, is there a way to have the median regardless if the month is not finished?
Please see sample raw data:

TeamTypeExtractedDateCnt
Team RedSedan02/09/20213
Team RedSedan03/09/20213
Team RedSedan09/09/20213
Team RedSedan27/08/20214
Team RedHatchback08/09/20214
Team RedHatchback09/09/20215
Team RedHatchback05/11/20211
Team BlueHatchback27/08/20211
Team BlueHatchback30/08/20211
Team BlueHatchback31/08/20212
Team BlueSedan17/11/20214
Team BlueSedan18/11/20214
Team BlueSedan19/11/20214
Team BlueHatchback27/10/20211
Team YellowHatchback09/09/20216
Team YellowHatchback10/09/20215
Team YellowHatchback13/09/20214
Team YellowSedan14/09/20213


Any tips? Thank you in advance

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try with minor changes

 

CalcuateData =
var calcType = Max('Calculate By'[ComputeBy])
RETURN
SWITCH(
TRUE(),
calcType = "Average", AVERAGEX(VALUES(car[ExtractedDate]), CALCULATE(SUM(car[Cnt]))),
MEDIANX(VALUES(car[ExtractedDate]),CALCULATE(SUM(car[Cnt])))
)

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@amitchandak Thank you! it works! 

amitchandak
Super User
Super User

@Anonymous , Try with minor changes

 

CalcuateData =
var calcType = Max('Calculate By'[ComputeBy])
RETURN
SWITCH(
TRUE(),
calcType = "Average", AVERAGEX(VALUES(car[ExtractedDate]), CALCULATE(SUM(car[Cnt]))),
MEDIANX(VALUES(car[ExtractedDate]),CALCULATE(SUM(car[Cnt])))
)

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.