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
slackerhx
Helper II
Helper II

Using result of MEDIANX in another measure

Hi, 

 

I'm trying to use the result of my first calculated measure in a second measure. 

 

1st Measure:

Median Rent = 

CALCULATE(MEDIANX('Table 1',[Rent PSM (Selected Currency)]),all('Table 1'[Client Name]),'Table 1'[Total Rent (USD)]<>BLANK())
 
where [Rent PSM (Selected Currency)] is a calculated measure that allows the results to be displayed based on the slicer for currency type eg. USD or EUR. 
 
2nd Measure: 
Difference = [Rent PSM (Selected Currency)] - [Median Rent]
 
The result (whenever recalculated) of the 1st measure is correct when i applied slicers such as City or Client Name to the card visual.
However, the result of 1st measure when placed in a table visual becomes incorrect as it recalculates based on individual address entries, which is more granular than city and client name.
 
I've attempted to use MEDIAN instead. Unfortunately, it wasn't a success as [Rent PSM (Selected Currency)] is a measure which the function doesn't accept. Perhaps, someone could suggest ways to incorporate a measure into the function?
 
Example: 
 
Card Visual = 28
 
Table Visual: 
 
Client NameCityAddressRent PSM (Selected Currency)Median RentDifference
ABCLondon3 Baker Street25250
XYZLondon26 Oxford Street40400
CDGLondon 9 Wellington Street28280
The ideal outputs should be as follow: 
 
Client NameCityAddressRent PSM (Selected Currency)Median RentDifference
ABCLondon3 Baker Street2528-3
XYZLondon26 Oxford Street402812
CDGLondon 9 Wellington Street28280

 

Thus, greatly appreciate if anyone can suggest solutions to achieve the above desired results. 

 

Thank you. 

1 ACCEPTED SOLUTION

Hi @slackerhx

 

You may try below measure:

Measure =
CALCULATE (
    MEDIANX ( ALLSELECTED ( Table1 ), [Rent PSM (Selected Currency)] ),
    Table1[Total Rent (USD)] <> BLANK ()
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
AlB
Super User
Super User

Hi @slackerhx

 

Have you tried to add an ALL( ) to get rid of the filter on the address in the table visual? Which filters do you want to keep when calculating the median, only the one on City? 

 

Median Rent=
CALCULATE ( MEDIANX ( 'Table 1', [Rent PSM (Selected Currency)] ), ALL ( 'Table 1'[Client Name], 'Table 1'[Address] ), 'Table 1'[Total Rent (USD)] <> BLANK () )

Hi @AlB,  

 

I've tried using all() on the address column but it still didn't give the desired result. 

 

I want to keep the filters for [Client Name] and [City] to recalculate the median. 

Hi @slackerhx

 

You may refer to below measure. If it is not your case, could you share the .pbix file so that we could help further on it?You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.

Median Rent =
CALCULATE (
    MEDIANX ( ALL ( 'Table 1' ), 'Table 1'[Rent PSM (Selected Currency)] ),
    'Table 1'[Total Rent (USD)] <> BLANK ()
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-cherch-msft Hi Cherie, 

 

I've tried your method, though it managed to make median constant, however, the median is not responsive to slicers for client name and city. 

 

I've done up a sample file to illustrate the issue. Please see attached link.

https://1drv.ms/u/s!AoVBzNM7bDanhH2XtlmnB_-zBsVR

 

Thank you!

 

Hi @slackerhx

 

You may try below measure:

Measure =
CALCULATE (
    MEDIANX ( ALLSELECTED ( Table1 ), [Rent PSM (Selected Currency)] ),
    Table1[Total Rent (USD)] <> BLANK ()
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the 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.