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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
FloBo
New Member

Using slicer under condition

Hi, I don't know if the title is really clear.

Here is my problem:
I have a report with pre-recorded date ranges that the user can select using a "Chiclet Slicer". Basically He can choose between 3 options : "W", "M" and "Y" (for Week, Month and Year) and I have 2 measures called StartDate and EndDate that use a combination of SWITCH and SELECTEDVALUE to determine what range to use.

e.g. if the users selects "M" then SartDate returns DATE( YEAR( TODAY() ); MONTH( TODAY() ); 1 ) and EndDate returns EOMONTH( TODAY() ).

Then I use those measures to calculate every others (DATESBETWEEN( Dates, StartDate, EndDate).

And it works fine.

But my users would like to add a 4th option to W/M/Y: they would like to have the possibility to select any date they want.

So I added a 4th chiclet called "C" (for Custom) and a classic date slicer where you can pick a start date and an end date. I also added this possibility in my SWITCH : MIN( Dates[Date] ) and MAX( Dates[Date] ).

This works pretty fine with all visuals that don't have a date axis. But when I put my measure on a column chart with dates on x axis I have a problem :
for example let say that my user picks up "A" (so from 01/01/2021 to today) and that the date slicer is between 02/01/2021 and 02/28/2021.

- If I say that the date slicer must filter the visual, it will only show the data in february, even if "A" is selected. It shows the correct data only if the date range in the slicer is larger than the range defined by the chiclet.

- If I say that the date slicer must NOT filter the visual it shows data properly when I pick up W/M/Y (because dates are calculated no mater what) BUT it shows all the data when I pick up "C" (because it doesn't care what is in the date slicer).

 

My question is: is it possible to do something like that? And if yes, how can I do?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @FloBo 

I think the you can try to build a filter measure, add this measure into visual filter and set it to show items when value = 1, when you want to get correct result in visuals with date axis.

My sample:

1.png

Table:

2.png

Build an unrelated date table.

Date = CALENDARAUTO()

My measure:

Filter =
VAR _Select =
    SELECTEDVALUE ( Chiclet[Chiclet] )
VAR _StartDate =
    SWITCH (
        TRUE (),
        _Select = "W",
            TODAY () - WEEKDAY ( TODAY (), 2 ) + 1,
        _Select = "M", DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 ),
        _Select = "Y", DATE ( YEAR ( TODAY () ), 01, 01 ),
        _Select = "C", MIN ( 'Date'[Date] )
    )
VAR _EndDate =
    SWITCH (
        TRUE (),
        _Select = "W",
            TODAY () + 7
                - WEEKDAY ( TODAY (), 2 ),
        _Select = "M", EOMONTH ( TODAY (), 0 ),
        _Select = "Y", DATE ( YEAR ( TODAY () ), 12, 31 ),
        _Select = "C", MAX ( 'Date'[Date] )
    )
RETURN
    IF (
        MAX ( 'Table'[Date] ) >= _StartDate
            && MAX ( 'Table'[Date] ) <= _EndDate,
        1,
        0
    )

 Result is as below.

3.png

You can download the pbix file from this link: File

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
FloBo
New Member

anks a lot @Anonymous !

Building an unrelated date table works perfectly!

Anonymous
Not applicable

Hi @FloBo 

I think the you can try to build a filter measure, add this measure into visual filter and set it to show items when value = 1, when you want to get correct result in visuals with date axis.

My sample:

1.png

Table:

2.png

Build an unrelated date table.

Date = CALENDARAUTO()

My measure:

Filter =
VAR _Select =
    SELECTEDVALUE ( Chiclet[Chiclet] )
VAR _StartDate =
    SWITCH (
        TRUE (),
        _Select = "W",
            TODAY () - WEEKDAY ( TODAY (), 2 ) + 1,
        _Select = "M", DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 ),
        _Select = "Y", DATE ( YEAR ( TODAY () ), 01, 01 ),
        _Select = "C", MIN ( 'Date'[Date] )
    )
VAR _EndDate =
    SWITCH (
        TRUE (),
        _Select = "W",
            TODAY () + 7
                - WEEKDAY ( TODAY (), 2 ),
        _Select = "M", EOMONTH ( TODAY (), 0 ),
        _Select = "Y", DATE ( YEAR ( TODAY () ), 12, 31 ),
        _Select = "C", MAX ( 'Date'[Date] )
    )
RETURN
    IF (
        MAX ( 'Table'[Date] ) >= _StartDate
            && MAX ( 'Table'[Date] ) <= _EndDate,
        1,
        0
    )

 Result is as below.

3.png

You can download the pbix file from this link: File

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors