Forum Discussion
Create a measure that returns values like a Field Parameter does
- 1 year ago
Anonymous
I made a change to your code and it worked. But do you know why it did not work when I did it your way?SelectedValueMeasure = SWITCH( TRUE(), SELECTEDVALUE('Parameter'[Parameter Fields]) = "'Table'[Amount]", SUM('Table'[Amount]), SELECTEDVALUE('Parameter'[Parameter Fields]) = "'Table'[Employee]", SUM('Table'[Employee]) )
Hi user01 ,
I create a table as you mentioned.
Then I think you can create a measure and here is the DAX code.
SelectedValueMeasure =
SWITCH(
TRUE(),
SELECTEDVALUE('Parameter'[Parameter]) = "Amount", SUM('Table'[Amount]),
SELECTEDVALUE('Parameter'[Parameter]) = "Employee", SUM('Table'[Employee])
)
You can use them and it will give you what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- user011 year agoResolver I
Anonymous
I got the following error:
Error fetching data for this visual
MdxScript(Model) (12, 5) Calculation error in measure 'Data2'[SelectedValueMeasure]: Column
[Parameter] is part of composite key, but not all columns of the composite key are included in the
expression or its dependent expression.
- user011 year agoResolver I
Anonymous
I made a change to your code and it worked. But do you know why it did not work when I did it your way?SelectedValueMeasure = SWITCH( TRUE(), SELECTEDVALUE('Parameter'[Parameter Fields]) = "'Table'[Amount]", SUM('Table'[Amount]), SELECTEDVALUE('Parameter'[Parameter Fields]) = "'Table'[Employee]", SUM('Table'[Employee]) )- Anonymous1 year agoNot applicable
Hi user01 ,
From the error message, the problem is because the Parameter column is part of the composite key and your expression does not contain all the columns of the composite key.
So it needs to be presented with the full column, like the 'Table'[Amount] you modified.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.