Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Oggie
Frequent Visitor

Filter a Measure with a parameter

Hi,
 
I am trying to write a measure that allows me to switch between different measures, where "KPI Net Revenue Act MTD" and "KPI Net Revenue Act YTD" are the "base measures" that should be shown in this card below as the large number (using the Subtitle field). I have managed to get one measure there but want to switch it using a filter.
 Oggie_4-1716554056893.png
I have set up the following measures. 
 
Oggie_3-1716553957172.png

 The measures are then grouped together using the Field Parameter function giving me a filter like the one below:

 Oggie_0-1716553771878.png

Oggie_2-1716553905791.png

 

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?

----
KPI Net Revenue Act = IF(SELECTEDVALUE('KPI Comparison Net Rev'[KPI Comparison Net Rev])="MTD vs Budget",FORMAT([Net Revenue Act MTD]/1000, "# ###"),FORMAT([Net Revenue Act YTD]/1000, "# ###"))
----
The current code gives me the following error:

Oggie_5-1716554443473.png

 

Kind of new to Power Bi and DAX... so could be easy... 🙂 Please help!

 

Best regards

Stefan

 
2 ACCEPTED SOLUTIONS
rajendraongole1
Super User
Super 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 !!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

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])
RETURN
IF(
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!

View solution in original post

2 REPLIES 2
rajendraongole1
Super User
Super 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 !!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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])
RETURN
IF(
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!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.