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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Libbyb23
Resolver I
Resolver I

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors