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
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
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.

Top Solution Authors