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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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])))
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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])))
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.