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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

How to Calculate Prior Day Total Daily Sales?

Hi, 

I am trying to calculate the Prior Day Total Sales. Tuesday would show Monday Total Sales, Saturday would show Friday Total Sales. Except Sunday would show Friday and Saturday Sales and Monday would show Friday, Saturday and Sunday Sales. I wrote the dax below but it isnt calculating correctly and I have tried using a Billing Date filter but it is incorrect.

PriorDaySales =
VAR CurrentDate = MAX('Billing Date'[Billing Date])
VAR CurrentYear = YEAR(CurrentDate)
VAR DayOfWeek = WEEKDAY(CurrentDate, 2)  


VAR SalesPriorDays =
    SWITCH(
        TRUE(),
        DayOfWeek = 6,  
            CALCULATE(
                SUM('Billed Orders'[BilledNetProductSales]),
                FILTER('Billing Date', 'Billing Date'[Billing Date] = CurrentDate - 1)  
            ) +
            CALCULATE(
                SUM('Billed Orders'[BilledNetProductSales]),
                FILTER('Billing Date', 'Billing Date'[Billing Date] = CurrentDate)  
            ),
        DayOfWeek = 7,  
            CALCULATE(
                SUM('Billed Orders'[BilledNetProductSales]),
                FILTER('Billing Date', 'Billing Date'[Billing Date] = CurrentDate - 1)  
            ) +
            CALCULATE(
                SUM('Billed Orders'[BilledNetProductSales]),
                FILTER('Billing Date', 'Billing Date'[Billing Date] = CurrentDate - 2)  
            ) +
            CALCULATE(
                SUM('Billed Orders'[BilledNetProductSales]),
                FILTER('Billing Date', 'Billing Date'[Billing Date] = CurrentDate)  
            ),
       
        CALCULATE(
            SUM('Billed Orders'[BilledNetProductSales]),
            FILTER('Billing Date','Billing Date'[Billing Date] = CurrentDate - 1)  
        )
    )

RETURN SalesPriorDays
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

I would use the WINDOW function to decide if I should look back to the previous day, the previous two days or the previous three days. Much simpler to implement.

 

lbendlin_0-1740442709217.png

 

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

I would use the WINDOW function to decide if I should look back to the previous day, the previous two days or the previous three days. Much simpler to implement.

 

lbendlin_0-1740442709217.png

 

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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