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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Dynamic calculated column to categorize date based on slicer

I'm trying to create a calculated column for my DIM_DATE which indicates which range does the date for into ("Last 7 days", "Last 8-14 days", "Last 15-21 days") based on my single selected date slicer. For instance, if I choose June 10, 2022, the column would show "Last 7 days" for June 5 and "Last 8-14 days" for June 1. 

 

The filter is based on DIM_DATE[THEDATE] column.

 

My current DAX formula is:

 

Date Category =
VAR SelectedDate = SELECTEDVALUE(DIM_DATE[THEDATE])
RETURN
SWITCH(TRUE(),
DIM_DATE[THEDATE] <= SelectedDate && DIM_DATE[THEDATE] > SelectedDate - 7, "Last 7 Days",
DIM_DATE[THEDATE] <= SelectedDate - 8 && DIM_DATE[THEDATE] > SelectedDate - 14, "Last 8-14 Days",
DIM_DATE[THEDATE] <= SelectedDate - 15 && DIM_DATE[THEDATE] >= SelectedDate - 21, "Last 15-21 Days","Other")
 
However, it is showing for all dates in my table to fall under "Other". Please refer to the picture below and let me know what is going wrong. Thanks!
 
BillNguyen_0-1655155055100.png

 

1 REPLY 1
Anonymous
Not applicable

Calculated columns and calculated tables are evaluated once when the data is loaded and are static until the data is refreshed.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.