Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
mith123
Frequent Visitor

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

1 ACCEPTED SOLUTION

hi @mith123 

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

View solution in original post

5 REPLIES 5
FreemanZ
Super User
Super User

hi @mith123 

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

 

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

mith123_0-1675826466762.png

 

hi @mith123 

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

@FreemanZ , You're the Best!! Thank you for all your help.

hi @mith123 

also learned from your case. 

So, in general, when there are multiple results to capture from a slicer, we either

1) use MIN/MAX instead of SELECTEDVALUE, to get the min/max value only;

or

2) use VALUES instead SELECTEDVALUE. But when nothing is selected, SELECTEDVALUE() returns blank, but VALUES() returns a full list, like ALL(). This not intuitive from the beginning. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.