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
dfox09
Helper III
Helper III

Set 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 value to show as 0 instead?  Here is the measure - 

Current =
CALCULATE(
MAXX(
'FactRFP',
[Total Annual Premium & FeesCURRENT]
),
REMOVEFILTERS('DimCarrier')
)
1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

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+0

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

6 REPLIES 6
Samarth_18
Community Champion
Community Champion

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+0

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

I did have one other question, that I just noticed. The visual starts with no selection, hence the request to have the initial (default) value to 0. However, when I select a client, a list of competing carriers will show up and the value is supposed to reflect that of the incumbent carrier (that is, the carrier that the client currently uses). What is actually happening is that when I select a client, the list of carriers shows up but the value doesn't change from 0, like it should. That may reflect a coding issue in the initial measure. Could you check to see what would cause it not to reflect the incumbent carrier value?

sevenhills
Super User
Super User

There 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

Thank 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?

@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 )

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

That worked! Thank for your suggestion. I will note this and the one you suggested below.

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.