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
RLangkemper
Regular Visitor

Using a measure in a Calculated(Sum( function

Hi,

 

There are some posts on using measures in calculated sum functions, but so far I've not been able to use these in solving my issue below. So I hope someone is able to help me out. 

I've got a table showing storage levels by location, on given reported dates by product. My colleagues looking at the dashboard like to use area charts (see below), hence I have some measures, to be able to plot individual years and averages/min/max etc. For example like this: 2019 = CALCULATE(SUM('Storage By location'[storage Amount]), 'Date mapping Table'[Year]=2019)

 
 

Storage.PNG
Now, because colleagues in different locations use different units, I've created a measure with a slicer that allows a dashboard user to switch between different units and the charts will automatically adjust (from this great post: https://www.fourmoo.com/2017/11/21/power-bi-using-a-slicer-to-show-different-measures/). This bit also works fine, when I create charts displaying the values from [selected measure].
 
Where I run into trouble is if I want to combine the two items above, since you can't use a measure in a sum().

So I have the dynamic measure, which is called [Selected Measure] and will show a value basis a slicer picking between two other measures.

Selected Measure =
VAR MySelection =
SELECTEDVALUE ('Measure selection'[Measure Name], "QTY in KBBL" )
RETURN
SWITCH (
TRUE (),
MySelection = "QTY in KT", [QTY in KT],
MySelection = "QTY in KBBL", [QTY in KBBL],
[QTY in KBBL]
)

Now I know what I want to do is not possible, but in order to explain what I am trying to do, I guess I just put the wrong formula here:
2019 = CALCULATE(SUM([Selected Measure], 'Date mapping Table'[Year]=2019)

So basically I am trying to change the storage amount to Selected Measure, but so far have been unable to crack this (last)bit. 

The date mapping table consists of a unique date column, a year and a weeknum column.
 
A long explanation, but I wanted to share as much info as I could without having to share my pbix file (since I can't).

Thanks!
Richard
0 REPLIES 0

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.