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

Value of a measure within a measure

I have a measure that calculates sales, this can be filtered based on store or salesperson etc... 

 

This then goes in a histogram showing distribution of stores or employees based on sales. 

 

User can select a store from a slicer.

 

I want to create a measure that will return a count of stores that fall within an arbitrary bin size (lets say max sales is 100$ and min is 0, with bin size of 10) for the sales of the store that the user selected. 

 

For example, user selects a store with sales of 73$, I want a count of all stores that fall within 70 and 80$ of sales. 

 

Is it possible to reference a measures value given a slicer within another measure?

 

Thank you.

1 ACCEPTED SOLUTION

After further thought, I have found a way to do this for anyone else experiencing the same problem: 

 

In the measure that you want to reference the filter context value of another measure you must first have a disconnected slicer, store the selected value in a var, then create a temp table using summarize and add a new column that contains the measure you want, then sum that table which will have only one row. Then that third var will contain the value within filter context.

 

This works of course only for single select filter but that was my use case. 

View solution in original post

3 REPLIES 3
Ritaf1983
Super User
Super User

Hi @DAX_merchant 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

@Ritaf1983, Due to the nature of the data and my employer, I can't share it. However if absolutely necessary, I can create a sample dataset that reflects similar functionality. 

 

However, I think my question is pretty straight forward and doesnt depend on data. I simply want to know if it is possible to extract the value of a measure in a given filter context within dax code. If I have a table with 100 rows and two columns, first column being the store ID of 10 stores (multiple entries for each store) and second column being sales, I can write a measure such as sum or average of sales. This will then give me some summary of sales but can be aggregated by store with a slicer in the UI. Can I extract the sum or average sales for one store within the code for another measure?

 

Similar to a pandas groupby if anyone is familiar with python. 

 

If this alone is not enough explanation of my problem then I figure it is not possible. 

 

Thank you. 

After further thought, I have found a way to do this for anyone else experiencing the same problem: 

 

In the measure that you want to reference the filter context value of another measure you must first have a disconnected slicer, store the selected value in a var, then create a temp table using summarize and add a new column that contains the measure you want, then sum that table which will have only one row. Then that third var will contain the value within filter context.

 

This works of course only for single select filter but that was my use case. 

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.