Forum Discussion
RLangkemper
6 years agoRegular 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)
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.
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:
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.
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
Thanks!
Richard
No RepliesBe the first to reply