Forum Discussion
Measure based on Slicer Selection
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
It is telling me that SELECTEDVALUE is not a valid function name. Any ideas?
- BA_Pete5 years agoSuper User
Ok. I guess you are using Direct Query mode rather than import?
Try this instead. I'm working on the assumption that your slicer is set to single-select on 'Date'[Week]:
Measure = VAR selectedAmount = [amount] VAR averageAmount = CALCULATE( [amount], 'Date'[Last 12 Weeks] = "Yes" ) / 12 RETURN if( selectedAmount > averageAmount, "yes", "no" )Pete
- EmmaWyeth5 years agoFrequent Visitor
Sorry for the delay, got called away on other reports.
Just tried this new bit of code, but am getting a syntax error. It reads exactly the same as yours above, any ideas?