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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
blazko
Helper III
Helper III

median filtered measure, counting 'empty records'

Hi, Id like to continue case from other topic 

median-of-calculated-median

 

the formula is:

Median Score = IF(
			ISFILTERED('Users'[user]),
			CALCULATE(MEDIAN('Users'[score])),
			MEDIANX('Sectors',CALCULATE(MEDIAN('Users'[score])))
		)

The solution works great but it seems to calculate through 'empty records'. If it calulates through a filterd list of users, but some user doesnt have scores in that calulated month (wasnt working that time), it adds a median=0. So the total median is calculated from ex not 4 numbers, but 7 (red marking below). it should give 51,38%, but gives 16,75% instead.

median.jpg


Tried to tweak with filters and so but nothing. Adding visual/page filter for measured median (I've inserted separate measure for
MEDIAN('Users'[score])
inside the code) ,for not blank, greater than 0, somehow messes it even more.

Its like its doing something "wrong" here:
MEDIANX('Sectors',CALCULATE(MEDIAN('Users'[score])))
How to exlude calculations that give here 0 as a result?

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @blazko,

 

Could you try the formula below to see if it works in your scenario?Smiley Happy

 

Median Score =
IF (
    ISFILTERED ( 'Users'[user] ),
    CALCULATE ( MEDIAN ( 'Users'[score] ) ),
    MEDIANX (
        FILTER ( 'Sectors', CALCULATE ( MEDIAN ( 'Users'[score] ) ) > 0 ),
        CALCULATE ( MEDIAN ( 'Users'[score] ) )
    )
)

Regards

View solution in original post

3 REPLIES 3
v-ljerr-msft
Employee
Employee

Hi @blazko,

 

Could you try the formula below to see if it works in your scenario?Smiley Happy

 

Median Score =
IF (
    ISFILTERED ( 'Users'[user] ),
    CALCULATE ( MEDIAN ( 'Users'[score] ) ),
    MEDIANX (
        FILTER ( 'Sectors', CALCULATE ( MEDIAN ( 'Users'[score] ) ) > 0 ),
        CALCULATE ( MEDIAN ( 'Users'[score] ) )
    )
)

Regards

OMG yes! Thank You!

v-shex-msft
Community Support
Community Support

Hi @blazko,

 

Can you please share the pbix file to test? I build a sample and test with your formula, it works on my side.

 

Capture.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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