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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. 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
Super User
Super User

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
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
ExcelMonke
Super User
Super User

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
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors