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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
jn123
Frequent Visitor

Slicer that filters a measure based on selection

Hi there, 

 

I am trying to write a SWITCH dax that allows me to filter a table of dates whenever I have "Previous Period" selected on a slicer. 

 

I have a date column, and a measure: 

Measure = IF(MIN('.Compare Date'[Date]) >= [Previous Period MIN] && MAX('.Compare Date'[Date]) <= [Previous Period MAX], 1 , 0)
 
jn123_0-1714757821835.png

 

 I also have a table that has a column of what I'd like to have as options in my slicer, "Previous Period"
 jn123_1-1714757911164.png

 

Now here's where I am stuck... I have written out a second measure that should filter the table when "Previous Period" is selected, but it doesn't appear to be doing anything. The data doesn't change whether I have "Previous Period" selected or not.... HELP!
 
jn123_2-1714759565770.png

 

Thanks in advance!!

1 ACCEPTED SOLUTION
ExcelMonke
Solution Supplier
Solution Supplier

Consider the following single measure:

Measure = 

VAR _Current = Your calculation
VAR _Previous = Your calculation

RETURN
SWITCH (
    SELECTEDVALUE ( 'Compare date Slicer'[Slicer Selection] ),
    "Current Period", _Current,
    "Previous Period", _Previous,
    0
)

View solution in original post

1 REPLY 1
ExcelMonke
Solution Supplier
Solution Supplier

Consider the following single measure:

Measure = 

VAR _Current = Your calculation
VAR _Previous = Your calculation

RETURN
SWITCH (
    SELECTEDVALUE ( 'Compare date Slicer'[Slicer Selection] ),
    "Current Period", _Current,
    "Previous Period", _Previous,
    0
)

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

Top Solution Authors