Forum Discussion
Filter a Measure with a parameter
The measures are then grouped together using the Field Parameter function giving me a filter like the one below:
Now I am trying to write a new measure that allows me to switch based on the selected value in the filter. Is it possible to write something like this?
Kind of new to Power Bi and DAX... so could be easy... 🙂 Please help!
Best regards
Stefan
Hi Oggie - Ensure that you have a base measure has been created,
create one more new measure as follows with selectedvalue func and add it to your card visual.
KPI Net Revenue Act =
VAR SelectedKPI = SELECTEDVALUE('KPI Comparison Net Rev'[KPI Comparison Net Rev])
RETURN
IF(
SelectedKPI = "MTD vs Budget",
FORMAT([Net Revenue Act MTD] / 1000, "# ###"),
FORMAT([Net Revenue Act YTD] / 1000, "# ###")
)try above and let know
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
I managed to solve it with your help, but I had to change the Selected value from "the composite key" to the actual field key, ie the code ended up like the following:
KPI Net Revenue Act =VAR SelectedKPI = SELECTEDVALUE('KPI Comparison Net Rev'[KPI Comparison Net Rev Fields])RETURNIF(SelectedKPI = "",'Measure groups'[KPI Net Revenue Act MTD vs Budget]FORMAT([Net Revenue Act MTD] / 1000, "# ###"),FORMAT([Net Revenue Act YTD] / 1000, "# ###"))Thanks for your help!
2 Replies
- rajendraongole1Super User
Hi Oggie - Ensure that you have a base measure has been created,
create one more new measure as follows with selectedvalue func and add it to your card visual.
KPI Net Revenue Act =
VAR SelectedKPI = SELECTEDVALUE('KPI Comparison Net Rev'[KPI Comparison Net Rev])
RETURN
IF(
SelectedKPI = "MTD vs Budget",
FORMAT([Net Revenue Act MTD] / 1000, "# ###"),
FORMAT([Net Revenue Act YTD] / 1000, "# ###")
)try above and let know
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
- OggieFrequent Visitor
I managed to solve it with your help, but I had to change the Selected value from "the composite key" to the actual field key, ie the code ended up like the following:
KPI Net Revenue Act =VAR SelectedKPI = SELECTEDVALUE('KPI Comparison Net Rev'[KPI Comparison Net Rev Fields])RETURNIF(SelectedKPI = "",'Measure groups'[KPI Net Revenue Act MTD vs Budget]FORMAT([Net Revenue Act MTD] / 1000, "# ###"),FORMAT([Net Revenue Act YTD] / 1000, "# ###"))Thanks for your help!