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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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