Forum Discussion
Measures, columns or parameters?
- 3 years ago
Unpivot your data. Instead of 50 columns have two - attribute and value. Then you can write one generic measure, or maybe even solve the question through the user interface.
- 3 years ago
Hi WardWijngaert ,
According to your description, here's my solution.
Sample:
1.Create a field parameter containing all the columns.
2.Creat three measures:
Measure = VAR _Field = SWITCH ( SELECTEDVALUE ( Parameter[Parameter Fields] ), "'Table'[Column1]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column1] = 20 ) ), "'Table'[Column2]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column2] = 20 ) ), "'Table'[Column3]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column3] = 20 ) ) ) RETURN DIVIDE ( _Field, COUNTROWS ( 'Table' ) )Measure2 = VAR _Field = SWITCH ( SELECTEDVALUE ( Parameter[Parameter Fields] ), "'Table'[Column1]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column1] = 14 ) ), "'Table'[Column2]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column2] = 14 ) ), "'Table'[Column3]", COUNTROWS ( FILTER ( 'Table', 'Table'[Column3] = 14 ) ) ) RETURN DIVIDE ( _Field, COUNTROWS ( 'Table' ) )Measure3 = [Measure] + [Measure 2]Put the parameter in a slicer, then get the correct result:
I attach my sample below for your reference.
Best regards,
Community Support Team_yanjiang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Great lbendlin & v-yanjiang-msft I tried both solutions and they work fine! Thank you very much for your help.
- v-yanjiang-msft3 years agoCommunity Support
Hi WardWijngaert ,
If you don't have other problems, please kindly mark the helpful reply as solution, then we'll close the thread, other people who has the same problem will benefit here.
Best regards,
Community Support Team_yanjiang