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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
love
Helper I
Helper I

How to return values based on if dates are within Slicer date range

Hello all 🙂

 

My user story: I would like to return values based on the following (in DAX)--> 

  1. If the "dates.start" (a date I get from a query called "Tasks") is earlier than the right date on my date slicer AND
  2. If the "dates.due" (also from the same query) is after the left date on my data slicer

THEN --> return 0 else 1.

 

When I say "date slicer" I am refering to the visualization:

Untitled.jpg

 

The field I am using for the data slicer comes from a separate calendar table ("CalendarTable") I created within PowerBI.

 

The formula I thought would work to meet the goals in the story above is:

CalculatedColumn = IF(AND(Tasks[dates.due]>FIRSTDATE(CalendarTable[Date]), Tasks[dates.start]<LASTDATE(CalendarTable[Date])), 0, 1)

The result with this code is that no matter how I set my date slicer, it always returns 0.

 

Thank you,

-L

1 ACCEPTED SOLUTION

Hi @love

 

Calculated ccolumns do not react to slicer selections

 

May be you could try a MEASURE instead

 

MEASURE =
IF (
    AND (
        SELECTEDVALUE ( Tasks[dates.due] ) > MIN ( CalendarTable[Date] ),
        SELECTEDVALUE ( Tasks[dates.start] ) < MAX ( CalendarTable[Date] )
    ),
    0,
    1
)

View solution in original post

3 REPLIES 3
love
Helper I
Helper I

/push

Hi @love

 

Calculated ccolumns do not react to slicer selections

 

May be you could try a MEASURE instead

 

MEASURE =
IF (
    AND (
        SELECTEDVALUE ( Tasks[dates.due] ) > MIN ( CalendarTable[Date] ),
        SELECTEDVALUE ( Tasks[dates.start] ) < MAX ( CalendarTable[Date] )
    ),
    0,
    1
)

Thank you very much @Zubair_Muhammad, your solution worked perfectly. Also great info about the columns, thanks again!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors