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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Saurabh129
Frequent Visitor

Selected Value: parameter for measures Error - Need help

I have a Parameter table which has 3 measures of having 3 different revisions of forecasts coming from 3 different tables. 

Saurabh129_0-1675338051368.png

These 3 measures contain 3 different revisions of forecasts ($) 

I created a slicer using this Parameter Table 

Saurabh129_1-1675338319497.png

 


Then I tried to create a measure  (Forecast $)  which will show the Forecast value $ depending upon which Forecast measure (revision) is picked.  (measure below)

Forecast $ =
SELECTEDVALUE (
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Forecasts'[Forecasts] = "Forecast 23 BP $", [Forecast 23 BP $]) ,
SELECTEDVALUE ( 'Forecasts'[Forecasts] =  "Forecast 1Q23RF $", [Forecast 1Q23RF $]) ,
SELECTEDVALUE ( 'Forecasts'[Forecasts] =  "Forecast 2Q23RF $", [Forecast 2Q23RF $]) ,
BLANK()
)

Saurabh129_2-1675338469190.png


Somehow the measure above is not working and giving error

Can someone please help here
Thank you so much !!

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Saurabh129 

The syntax of SELECTEDVALUE & SWITCH is not quite right, and also SELECTEDVALUE cannot be used with the first column of a Field Parameter table (see this article).

 

Here is one way you could rewrite it:

Forecast $ =
VAR FieldParameterSelection =
    IF (
        COUNTROWS ( 'Forecasts' ) = 1,
        VALUES ( 'Forecasts'[Forecasts] )
    )
RETURN
    SWITCH (
        FieldParameterSelection,
        "Forecast 23 BP $", [Forecast 23 BP $],
        "Forecast 1Q23RF $", [Forecast 1Q23RF $],
        "Forecast 2Q23RF $", [Forecast 2Q23RF $]
        -- BLANK() will be returned in the case of no match
    )

I'm assuming you're creating this measure so that you can write DAX expressions that reference it elsewhere, or do something that doesn't work with the normal behaviour of field parameters.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
Saurabh129
Frequent Visitor

Thank you so much for your help 

It worked

OwenAuger
Super User
Super User

Hi @Saurabh129 

The syntax of SELECTEDVALUE & SWITCH is not quite right, and also SELECTEDVALUE cannot be used with the first column of a Field Parameter table (see this article).

 

Here is one way you could rewrite it:

Forecast $ =
VAR FieldParameterSelection =
    IF (
        COUNTROWS ( 'Forecasts' ) = 1,
        VALUES ( 'Forecasts'[Forecasts] )
    )
RETURN
    SWITCH (
        FieldParameterSelection,
        "Forecast 23 BP $", [Forecast 23 BP $],
        "Forecast 1Q23RF $", [Forecast 1Q23RF $],
        "Forecast 2Q23RF $", [Forecast 2Q23RF $]
        -- BLANK() will be returned in the case of no match
    )

I'm assuming you're creating this measure so that you can write DAX expressions that reference it elsewhere, or do something that doesn't work with the normal behaviour of field parameters.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors