Forum Discussion
DAX if not filtered, insert filter
- 6 years ago
The problem is in the final CALCULATE: the first argument of CALCULATE needs to be the expression to return, and the subsequent argument(s) are filters to apply.
Something like the below code should work.
It's probably not necessary in your model, but in the below code I also changed DISTINCT to SELECTEDVALUE, as it's a little safer. SELECTEDVALUE always returns a single value if there is only one value in the specified column, otherwise blank (or an optional second argument).
Text = IF ( ISFILTERED ( Businessunit[BU] ); IF ( HASONEFILTER ( Businessunit[BU] ); SELECTEDVALUE ( Comments[text] ); "select one business unit" ); CALCULATE ( SELECTEDVALUE ( Comments[text] ); Businessunit[BU] = "Overall" ) )Regards
Owen
The problem is in the final CALCULATE: the first argument of CALCULATE needs to be the expression to return, and the subsequent argument(s) are filters to apply.
Something like the below code should work.
It's probably not necessary in your model, but in the below code I also changed DISTINCT to SELECTEDVALUE, as it's a little safer. SELECTEDVALUE always returns a single value if there is only one value in the specified column, otherwise blank (or an optional second argument).
Text =
IF (
ISFILTERED ( Businessunit[BU] );
IF (
HASONEFILTER ( Businessunit[BU] );
SELECTEDVALUE ( Comments[text] );
"select one business unit"
);
CALCULATE ( SELECTEDVALUE ( Comments[text] ); Businessunit[BU] = "Overall" )
)Regards
Owen
Thanks Owen. Works like a charm!