Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Unable to select multiple values in slicer and pass to datesbetween function

Hi Everyone,

I need help.

 

I have a DAX measure which works fine with a single value selected in the slicer but when multiple values are selected this doesn't work as expected. Can someone please guide me? Thank you for the help

 

Sales New Measure =
VAR SlicerSelection = SELECTEDVALUE('Calendar'[DAY_OF_WEEK_NM])
RETURN IF(SlicerSelection=BLANK(),[Sales Dynamic],CALCULATE(sum(Purchase[Sales]),
DATESBETWEEN('Calendar'[CALENDAR_DT], [Min Date], [Max Date]), 'Calendar'[DAY_OF_WEEK_NM] = SlicerSelection))

  • FreemanZ's avatar
    FreemanZ
    3 years ago

    hi Anonymous 

    try like:

    Sales New Measure =
    VAR SlicerSelection = 
    VALUES('Calendar'[DAY_OF_WEEK_NM])
    RETURN 
    IF(
        COUNTROWS(SlicerSelection)= COUNTROWS(ALL('Calendar'[DAY_OF_WEEK_NM])) ,
        [Sales Dynamic],
        CALCULATE(
            sum(Purchase[Sales]),
            DATESBETWEEN(
                'Calendar'[CALENDAR_DT], 
                [Min Date], 
                [Max Date]
            ), 
           'Calendar'[DAY_OF_WEEK_NM] IN SlicerSelection
        )
    )

5 Replies

  • hi Anonymous 

    try like:

     

    Sales New Measure =
    VAR SlicerSelection = 
    VALUES('Calendar'[DAY_OF_WEEK_NM])
    RETURN 
    IF(
        SlicerSelection=BLANK(),
        [Sales Dynamic],
        CALCULATE(
            sum(Purchase[Sales]),
            DATESBETWEEN(
                'Calendar'[CALENDAR_DT], 
                [Min Date], 
                [Max Date]
            ), 
           'Calendar'[DAY_OF_WEEK_NM] IN SlicerSelection
        )
    )

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you FreemanZ for helping. I did the changes but got the following error. Please advise. Thank you

       

      • FreemanZ's avatar
        FreemanZ
        Icon for Super User rankSuper User

        hi Anonymous 

        try like:

        Sales New Measure =
        VAR SlicerSelection = 
        VALUES('Calendar'[DAY_OF_WEEK_NM])
        RETURN 
        IF(
            COUNTROWS(SlicerSelection)= COUNTROWS(ALL('Calendar'[DAY_OF_WEEK_NM])) ,
            [Sales Dynamic],
            CALCULATE(
                sum(Purchase[Sales]),
                DATESBETWEEN(
                    'Calendar'[CALENDAR_DT], 
                    [Min Date], 
                    [Max Date]
                ), 
               'Calendar'[DAY_OF_WEEK_NM] IN SlicerSelection
            )
        )