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
wcarter
Advocate II
Advocate II

Calculate measure with date offset of intermittent dates

My scenario: I have a date table spanning 10 years, on this table are also marked major holidays; on another table are dates and some value for each date. I need to filter the second table by the first table with an optional offset value. For example, if I filter for Halloween I want to know the value of my second table for each Halloween of the previous 10 years (this is easy and I have solved this), but if I also set an offset of +1, -3, +4 etc, I want to know instead what the value was on the day after Halloween, three days before halloween, four days after hallowen, etc. I've tried various combinations of filtering and lookupvalue and keep getting errors or no results, for example

 

ValueHoliday =
 CALCULATE(SUM(Table2[Column2]),FILTER(DateTable,DateTable[Index] IN VALUES(Holidays[Index]))
 
works fine, but I need something like:
ValueHoliday =
 CALCULATE(SUM(Table2[Column2]),FILTER(DateTable,DateTable[Index] IN VALUES(Holidays[Index]) + SELECTEDVALUE(OFFSET[VALUE]))

 

Any help would be greatly appreciated, the offset portion is proving very challenging.

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

try this one,it makes use of TREATAS:
https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/

ValueHoliday =
VAR _offset =
    SELECTEDVALUE ( OFFSET[VALUE] )
VAR _dates =
    VALUES ( Holidays[Index] )
VAR _dates_offset =
    SELECTCOLUMNS (
        ADDCOLUMNS ( _dates, "@offset", [Index] + _offset ),
        "@offset", [@offset]
    )
RETURN
    CALCULATE (
        SUM ( Table2[Column2] ),
        TREATAS ( _dates_offset, DateTable[Index] )
    )

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

1 REPLY 1
Stachu
Community Champion
Community Champion

try this one,it makes use of TREATAS:
https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/

ValueHoliday =
VAR _offset =
    SELECTEDVALUE ( OFFSET[VALUE] )
VAR _dates =
    VALUES ( Holidays[Index] )
VAR _dates_offset =
    SELECTCOLUMNS (
        ADDCOLUMNS ( _dates, "@offset", [Index] + _offset ),
        "@offset", [@offset]
    )
RETURN
    CALCULATE (
        SUM ( Table2[Column2] ),
        TREATAS ( _dates_offset, DateTable[Index] )
    )

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors