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
gmasta1129
Resolver I
Resolver I

Previous Day Function (Weekends excluded)

Hello,

 

I have data for Monday to Friday only. 

 

I am using the formula below to compare the previous day minus today's values.  My issue is with Monday's calculation showing that there is a difference since it cannot find Sunday's data.  What i need the formula to do is to exclude sat and sun so that the formula finds Friday's data and subtracts it by Mondays data.  

 

DOD NAV Difference = SUM(daily_report[total value usd])-CALCULATE(SUM(daily_report[total value usd]),PREVIOUSDAY('daily_report'[date time]))

2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@gmasta1129 

You can use the following measure to get the desired results.

Difference =
VAR __CurrentDate =
    MAX ( 'daily_report'[date time] )
VAR _LastDate =
    LASTDATE (
        FILTER (
            ALL ( 'daily_report'[date time] ),
            'daily_report'[date time] < __CurrentDate
                && NOT WEEKDAY ( 'daily_report'[date time], 2 ) IN { 6, 7 }
        )
    )
VAR __Result =
    CALCULATE ( SUM ( daily_report[total value usd] ), _LastDate )
RETURN
    __Result
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

Hello,

 

It worked! i just made a small change to the VAR Result portion of the formula you sent.  

 

Thank you so much for your help!!! I was working on it for hours to try and figure it out before i went to this website.  

 

 

 

View solution in original post

4 REPLIES 4
gmasta1129
Resolver I
Resolver I

Hello,

 

I copy and pasted the formula.  See results below.  It looks like it did not work as i have differences in all.  

 

gmasta1129_0-1642923290320.png

 

@gmasta1129 

It's hard to understand how you have set up your model. If you could share a dummy file then I can check it and revert to you.

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Fowmy
Super User
Super User

@gmasta1129 

You can use the following measure to get the desired results.

Difference =
VAR __CurrentDate =
    MAX ( 'daily_report'[date time] )
VAR _LastDate =
    LASTDATE (
        FILTER (
            ALL ( 'daily_report'[date time] ),
            'daily_report'[date time] < __CurrentDate
                && NOT WEEKDAY ( 'daily_report'[date time], 2 ) IN { 6, 7 }
        )
    )
VAR __Result =
    CALCULATE ( SUM ( daily_report[total value usd] ), _LastDate )
RETURN
    __Result
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hello,

 

It worked! i just made a small change to the VAR Result portion of the formula you sent.  

 

Thank you so much for your help!!! I was working on it for hours to try and figure it out before i went to this website.  

 

 

 

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.