Forum Discussion
call two different measure parameter in DAX
Hi All,
I have created two measure parameter, Parameter1 contains 3 measure as M1,M2 & M3. Parameter2 contains 2 measures M4,M5. If I directly call this parameter in table visual, it works fine and displayes individual measures of that parameter, but what I want is, if select Group1 from slicer, I want to show Measures of Parameter1 in table visual, basically want to call Parameter1 table. If I select Group2 from slicer, I want to show measures of Parameter2.
- Anonymous2 years ago
Hi Anonymous ,
I suggest you to create one parameter with all measure names and then add a Group column.
Group = IF(Parameter[Parameter] in {"M1","M2","M3"},"Group1","Group2")Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- DallasBaba
Skilled Sharer
Hi Anonymous
You can dynamically use field parameters to change the measures or dimensions.
To get started, you need to enable the Field parameters preview feature.
Go to File > Options and Settings> Options > Preview features in Power BI Desktop. Select the Field parameters.
Once enabled, you can create a new
Measure =
IF (
SELECTEDVALUE ( 'Table'[Group] ) = "Group1",
[Parameter1.M1] + [Parameter1.M2] + [Parameter1.M3],
[Parameter2.M4] + [Parameter2.M5]
)
See relevant solution:
https://community.fabric.microsoft.com/t5/Desktop/using-parameter-values-in-visual-filter/m-p/294517
You can also learn more about field parameters
https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters
I hope this help
Thanks
Babatunde Dallas
- AnonymousNot applicable
DallasBaba may be I have not explained it correctly. Basically I have created Field parameter on front end. Parameter1 contains 3 measures M1 (sum(M1)), M2 and M3 respectively. when I select Group1, I want to show values of M1, M2 & M3 in the report. So report would look like below
Dimension1 M1 M2 M3 A 10 20 30 Similarly, if I select Group2, In same table visual, I would like to see values of measures M4 & M5.
- AnonymousNot applicable
Hi Anonymous ,
I suggest you to create one parameter with all measure names and then add a Group column.
Group = IF(Parameter[Parameter] in {"M1","M2","M3"},"Group1","Group2")Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- DallasBaba
Skilled Sharer
Anonymous you can accomplish this by creating a measure that switches between Parameter1 and Parameter2 based on the slicer selection.
Create a measure that selects the appropriate set of measures based on the slicer value:
Dynamic Measures =
VAR SelectedGroup = SELECTEDVALUE('Table'[Group])
RETURN
SWITCH(
SelectedGroup,
"Group1", [Parameter1.M1] + [Parameter1.M2] + [Parameter1.M3],
"Group2", [Parameter2.M4] + [Parameter2.M5],
BLANK()
)
Then create a table visual in your report with "Dimension1" as a dimension and use the "Dynamic Measures" measure as values.
When you select "Group1" in the slicer, it will display the sum of M1, M2, and M3.
When you select "Group2," it will show the sum of M4 and M5.The table visual should look like this:
let me know if this works
Thanks