Forum Discussion
Selected Value: parameter for measures Error - Need help
- 3 years ago
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
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