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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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