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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
StuartSmith
Power Participant
Power Participant

If condition based on slicer selection

I have a slicer connected to a "Date" table with a hirarchy of...

StuartSmith_0-1694720386352.png

 

Is there a way to create an "IF" measure that can use the slicer selection?  Something like IF(Slicer Selection = "1st Half", "Blah", "Blah Bah")

 

Thanks in advance.

 

5 REPLIES 5
StuartSmith
Power Participant
Power Participant

Quick Idea: 

I actually have a table that displays the "First" & "Last" date of the slicer selection.  Is there a way too use these dates such as

IF(DatesBetween(FirstDate, LastDate)=365, "Year",

IF(DatesBetween(FirstDate, LastDate)=182, "1st Half",  and so on, 

 

I could manually work out how many days are in Jan, Feb, Mar, Apr, May & Jun for 1st Half, etc. but is there an automatic way such as a function to callculate dates, to cover leap years, etc.

StuartSmith_0-1694722286045.png

 

@StuartSmith ,

I am not sure if I will be able to help you to that extent as I am pretty new to Power BI myself. The response that I have given is working perfectly. So do give it a try.

 

Sorry, our posts crossed.  I'll try your solution later and get back to you. Thanks

Sure @StuartSmith 

 

ChiragGarg2512
Solution Sage
Solution Sage

Measure =
var _date = VALUES(Sales[Delivery Date].[QuarterNo])
return
if(_date <= 2, "Blah", "Blah bah")
 
Create a measure with the above DAX. Change the values in the VALUES function to column name of your table. 
ChiragGarg2512_0-1694722831866.png

 

For doing this for 1st and 2nd Half add that particular hierarchy to the DAX, i.e. Sales[Delivery Date].[Half]

 

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.