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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Responsive Resident
Responsive Resident

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
Responsive Resident
Responsive Resident

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.