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
Anonymous
Not applicable

Subtracting the Value of One Day from it's Previous Day

Hi everyone, how are you?

 

I'm finding difficulties here to build a measure. I have 2 colums, one with the date and other with the value. I would like to create a new column or measure, to result in the difference between one date and its previous date.

But my problem is: the column date doesn't have equivalent subsequent dates, I don't have Saturdays and Sundays for example, and if I would like to have the difference between Monday and last Friday, I can't find any DAX formula to resolve it.

Here is a picture of my table and what I would like to resolve:

RodCamargoJr_0-1671117888906.png

 

Is there any way that I can index my dates? Or I assume that the previous day is not necessary DAY - 1 ? 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

It seems like you need to find out hit nearest working days based on current date.

For his scenario, you can consider adding workday as condition to your expression and max function to find the biggest one from current date.

Measure formula:

formula =
VAR currDate =
    MAX ( Table[Date] )
VAR prevDate =
    CALCULATE (
        MAX ( Table[Date] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            WEEKDAY ( [Date], 2 ) <= 5
                && [Date] < currDate
        )
    )
RETURN
    CALCULATE (
        SUM ( Table[Value] ),
        FILTER ( ALLSELECTED ( 'Table' ), Table[Date] = prevDate )
    )

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Mahesh0016
Super User
Super User

VAR  Value = sum(Table[Value])
VAR PreviousRow = CALCULATE( Value , OFFSET( -1, ALLSELECTED('Product'[Product]), ORDERBY('Product'[Product], ASC) ) )
RETURN Value - PreviousRow

If this post helps, please consider accept as solution to help other members find it more quickly.
Thank You!

Anonymous
Not applicable

Hi @Anonymous,

It seems like you need to find out hit nearest working days based on current date.

For his scenario, you can consider adding workday as condition to your expression and max function to find the biggest one from current date.

Measure formula:

formula =
VAR currDate =
    MAX ( Table[Date] )
VAR prevDate =
    CALCULATE (
        MAX ( Table[Date] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            WEEKDAY ( [Date], 2 ) <= 5
                && [Date] < currDate
        )
    )
RETURN
    CALCULATE (
        SUM ( Table[Value] ),
        FILTER ( ALLSELECTED ( 'Table' ), Table[Date] = prevDate )
    )

Regards,

Xiaoxin Sheng

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.