Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Dynamic isfiltered dax expression

Hi Experts,

 

I have a scenario as follows:

 

If filter (slicer) does not have any selected value (Year/Month) then the table should show current months sales.

when the Year/Month is filtered (selected on slicer) then the table should show the data for that selected Year/Month.

 

please show me how can i create the dax expression.

 

Thanks.

  • Hi Anonymous ,

     

    To create a measure as below.

     

    measure = 
    VAR sum1 =
        SUM ( 'Table'[value] )
    VAR sumcurrecnt =
        CALCULATE (
            SUM ( 'Table'[value] ),
            FILTER (
                'Table',
                YEAR ( 'Table'[Date] ) = YEAR ( TODAY () )
                    && MONTH ( 'Table'[Date] ) = MONTH ( TODAY () )
            )
        )
    RETURN
        IF ( ISFILTERED ( 'Table'[year month] ), sum1, sumcurrecnt )
    

    Pbix as attached.

     

2 Replies

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi Anonymous ,

     

    To create a measure as below.

     

    measure = 
    VAR sum1 =
        SUM ( 'Table'[value] )
    VAR sumcurrecnt =
        CALCULATE (
            SUM ( 'Table'[value] ),
            FILTER (
                'Table',
                YEAR ( 'Table'[Date] ) = YEAR ( TODAY () )
                    && MONTH ( 'Table'[Date] ) = MONTH ( TODAY () )
            )
        )
    RETURN
        IF ( ISFILTERED ( 'Table'[year month] ), sum1, sumcurrecnt )
    

    Pbix as attached.

     

  • Anonymous you can use hasonefilter function to check if any value is selected or not and based on that change your calculation.