Forum Discussion
dfox09
Helper III
4 years agoSet the default value for slicer to 0
Here is the DAX for a Slicer that I am using to show revenue amount based on a carrier selected. If no carrier is selected, ir shows the total value for all of the carriers. How do I get the default ...
- 4 years ago
Hi dfox09 ,
You can try this:-
measure = VAR result = CALCULATE ( MAXX ( 'FactRFP', [Total Annual Premium & FeesCURRENT] ), REMOVEFILTERS ( 'DimCarrier' ) ) RETURN COALESCE ( result, 0 ) --or you can try below --if(result = blank(),0,result) --or --result+0Thanks,
Samarth
sevenhills
Super User
4 years agoThere is no default value setting for slicer as per my knowledge. But you can use ISFILTERED and try change the value. Hope this helps!
Measure Name =
var _ValueCalculated = <... Your Calculation >
RETURN
IF( ISFILTERED( 'FilterTable'[FilterColumn] ), _ValueCalculated, 0 )
https://docs.microsoft.com/en-us/dax/isfiltered-function-dax
dfox09
Helper III
4 years agoThank you for your offer of help. I tried your suggestion and wondering if I missed something. Here is the code with your suggested setup:
var _ValueCalculated = CALCULATE(
MAXX(
'FactRFP',
[Total Annual Premium & FeesCURRENT]
),
REMOVEFILTERS('DimCarrier')
RETURN IF
( ISFILTERED(DimCarrier[Carrier]), _ValueCalculated, 0 )
I get the following error:
The syntax for 'RETURN' is incorrect. (DAX(CALCULATE( MAXX( 'FactRFP', [Total Annual Premium & FeesCURRENT] ), REMOVEFILTERS('DimCarrier')) RETURN IF( ISFILTERED( 'FilterTable'[FilterColumn] ), _ValueCalculated, 0 ) --wip)). What should I change?
- Samarth_184 years ago
Community Champion
dfox09 Based on sevenhills suggestion below would be your ideal code:-
measure = VAR _ValueCalculated = CALCULATE ( MAXX ( 'FactRFP', [Total Annual Premium & FeesCURRENT] ), REMOVEFILTERS ( 'DimCarrier' ) ) RETURN IF ( ISFILTERED ( DimCarrier[Carrier] ), _ValueCalculated, 0 )- dfox094 years ago
Helper III
That worked! Thank for your suggestion. I will note this and the one you suggested below.