Forum Discussion
EmmaWyeth
5 years agoFrequent Visitor
Measure based on Slicer Selection
Hi All I am trying to write a calculation measure in Power BI, to work out if this week's volumes are greater or less than the average of the last 12 weeks volumes. If greater then "yes" otherwi...
BA_Pete
5 years agoSuper User
Hi EmmaWyeth ,
I'm not sure if I've understood your requirement correctly, but to pick up a slicer value to use in a measure you can use SELECTEDVALUE(). For example:
_example =
IF(
SELECTEDVALUE(xTable[WeekNumber], 5) = 1,
SUM(xTable[Sales])
)
Pete
- EmmaWyeth5 years agoFrequent Visitor
Hi Pete
I tried SELECTEDVALUES, but it wasn't an option. Is this a Power BI version thing?
- BA_Pete5 years agoSuper User
Hi EmmaWyeth ,
Almost certainly not a Power BI version thing, unless you're on the October 1982 release.
Very difficult to diagnose exactly what the issue is without seeing your actual data/model/calculations etc., but I believe your required measure should look *something* like this, assuming that your slicer selects 'Date'[Week]:
Measure = VAR selectedAmount = CALCULATE( [amount], 'Date'[Week] = SELECTEDVALUE('Date'[Week]) ) VAR averageAmount = CALCULATE( [amount], 'Date'[Last 12 Weeks] = "Yes" ) / 12 RETURN if( selectedAmount > averageAmount, "yes", "no" )Pete
- EmmaWyeth5 years agoFrequent Visitor
It is telling me that SELECTEDVALUE is not a valid function name. Any ideas?