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
aroucadaniel
Frequent Visitor

Return penultimate date from a table

Hello!

 

I need to calculate the daily change in the value of a column. My base has a Calendar Dimension, and the idea is to create a measure that makes the variation based on the previous working day.

 

I've already tried to use the DAX function "PROVIOUSDAY" and the "DATE ​​ADD", but this creates a problem because it literally searches for a previous day and not the previous date available in the Calendar Dimension (which only has working days).

1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

First, your calendar should indeed have ALL THE DAYS, not only working days. This is needed for the time-intel functions to work correctly (please, for instance consult this page). Second, it's easy to find the previous working day for a given day if you have a proper calendar and there's a column in there that informs you whether or not a day is working/non-working.

Here's a measure that gets you such a day with ease:

 

[Prev Working Day] =
// If multiple days are visible, the base
// for the calculation will be the very
// first day in the context. If only one
// day is visible, this very day will be
// the point of orientation. You can adjust
// this logic to your liking. Please don't
// forget to MARK your Dates as a Date Table
// in the model so that it works as expected
// with the time-intel functions.
var FirstDayVisible = MIN( Dates[Date] )
var PrevWorkingDay =
    calculate(
        selectedvalue( Dates[Date] ),
        Dates[Date] < FirstVisibleDay,
        // Day Type should be a column with
        // 2 distinct values in it: working,
        // non-working. Please note that 
        // DAX is case-insensitive.
        Dates[Day Type] = "working",
        // This is technically unnecessary
        // IF your Dates are marked as
        // a Date Table. If not, you have
        // to keep it.
        removefilters( Dates )
    )
return
    PrevWorkingDay

 

 

 

View solution in original post

1 REPLY 1
daXtreme
Solution Sage
Solution Sage

First, your calendar should indeed have ALL THE DAYS, not only working days. This is needed for the time-intel functions to work correctly (please, for instance consult this page). Second, it's easy to find the previous working day for a given day if you have a proper calendar and there's a column in there that informs you whether or not a day is working/non-working.

Here's a measure that gets you such a day with ease:

 

[Prev Working Day] =
// If multiple days are visible, the base
// for the calculation will be the very
// first day in the context. If only one
// day is visible, this very day will be
// the point of orientation. You can adjust
// this logic to your liking. Please don't
// forget to MARK your Dates as a Date Table
// in the model so that it works as expected
// with the time-intel functions.
var FirstDayVisible = MIN( Dates[Date] )
var PrevWorkingDay =
    calculate(
        selectedvalue( Dates[Date] ),
        Dates[Date] < FirstVisibleDay,
        // Day Type should be a column with
        // 2 distinct values in it: working,
        // non-working. Please note that 
        // DAX is case-insensitive.
        Dates[Day Type] = "working",
        // This is technically unnecessary
        // IF your Dates are marked as
        // a Date Table. If not, you have
        // to keep it.
        removefilters( Dates )
    )
return
    PrevWorkingDay

 

 

 

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.