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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
victoryamaykin
Advocate I
Advocate I

DAX Sales Total for the Same DAY (not Date) Last Year -- How does this work?

Could someone please explain how to write a DAX measure for the total sales of the same DAY last year? 
I've seen the other posts, but none of them worked for me. 

I am looking for the sales on the same day of the week, not the date. 

---- 
(not working DAX) 

Sales Same Day Last Year =

    CALCULATE (
        [Total Sales],  -- Sum sales for the calculated dates
        FILTER (
            'Calendar',
            'Calendar'[Same Day Last Year] = SELECTEDVALUE(Data[Date]) -- What were the sales on the same day of the week last year
        )
    )

---- 

Here is my file
https://drive.google.com/file/d/1Ppu2BR1ZZ_vpxM3jCKnmHgUzGuTI0XTJ/view?usp=sharing

victoryamaykin_0-1729716539356.png

 

1 ACCEPTED SOLUTION

Ah - here ya go:

SalesSameWeekDayLastYear =
VAR CurrentDate = MAX('Calendar'[Date])
VAR CurrentWeek = WEEKNUM(CurrentDate)
VAR CurrentDayOfWeek = WEEKDAY(CurrentDate)
VAR LastYearDate =
    CALCULATE(
        MAX('Calendar'[Date]),
        'Calendar'[Year] = YEAR(CurrentDate) - 1,
        WEEKNUM('Calendar'[Date]) = CurrentWeek,
        WEEKDAY('Calendar'[Date]) = CurrentDayOfWeek
    )
RETURN
    CALCULATE(
        [Sales],
        'Calendar'[Date] = LastYearDate
    )
 
audreygerred_1-1729785987374.png

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

6 REPLIES 6
audreygerred
Super User
Super User

Hi! You can make the folowing measures:

Total Sales = SUM ('YouTable'[YourSalesField]

Total Sales LY = CALCULATE ([Total Sales], SAMEPERIODLASTYEAR ('DateTable'[Date])

 

Then, in your table, put in the date field from your date table and both of your measures. Have a date filter and filter to today (or whatever day you want) and the Total Sales measure will display this year amount and Total Sales LY will be the same date in the previous year.

 

I updated your file 🙂 https://drive.google.com/file/d/1Ppu2BR1ZZ_vpxM3jCKnmHgUzGuTI0XTJ/view?usp=drive_link





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you, but I am looking for the same day, not the same date last year. Any help is appreciated greatly. I'm still new to DAX, so I don't fully understand the FILTER function. 

I have a calculated column that finds the same day last year. 

Same Day Last Year =
VAR _dt = [Date]
VAR _weekDay = WEEKDAY(_dt, 2)  -- Returns the day of the week (Monday=1, Sunday=7)
VAR _yearAgo = _dt - 364        -- Approximate the date a year ago
VAR _weekAdjustment =
    _weekDay - WEEKDAY(_yearAgo, 2) -- Difference in weekday from the same date last year

RETURN
    _yearAgo + _weekAdjustment


--- 

But this DAX code is not working: 

--- 

Sales Same Day Last Year =

    CALCULATE (
        [Total Sales],  -- Sum sales for the calculated dates
        FILTER (
            'Calendar',
            'Calendar'[Same Day Last Year] = SELECTEDVALUE(Data[Date]) -- What were the sales on the same day of the week last year
        )
    )

Ah - here ya go:

SalesSameWeekDayLastYear =
VAR CurrentDate = MAX('Calendar'[Date])
VAR CurrentWeek = WEEKNUM(CurrentDate)
VAR CurrentDayOfWeek = WEEKDAY(CurrentDate)
VAR LastYearDate =
    CALCULATE(
        MAX('Calendar'[Date]),
        'Calendar'[Year] = YEAR(CurrentDate) - 1,
        WEEKNUM('Calendar'[Date]) = CurrentWeek,
        WEEKDAY('Calendar'[Date]) = CurrentDayOfWeek
    )
RETURN
    CALCULATE(
        [Sales],
        'Calendar'[Date] = LastYearDate
    )
 
audreygerred_1-1729785987374.png

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





It's working in the test file, but I can't get it to work in my main file. Any idea why it's the same number? 

Items Produced Same Week Day Last Year =

VAR CurrentDate = MAX(DimDates[Date])
VAR CurrentWeek = WEEKNUM(CurrentDate)
VAR CurrentDayOfWeek = WEEKDAY(CurrentDate)
VAR LastYearDate =
    CALCULATE(
        CurrentDate,
        DimDates[Year] = YEAR(CurrentDate) - 1,
        WEEKNUM(DimDates[Date]) = CurrentWeek,
        WEEKDAY(DimDates[Date]) = CurrentDayOfWeek
    )
RETURN
    CALCULATE(
        [Items Produced],
        DimDates[Date] = LastYearDate
    )




victoryamaykin_0-1729791017661.png

 

Hi! Looks like you have this:

Items Produced Same Week Day Last Year =

 

VAR CurrentDate = MAX(DimDates[Date])
VAR CurrentWeek = WEEKNUM(CurrentDate)
VAR CurrentDayOfWeek = WEEKDAY(CurrentDate)
VAR LastYearDate =
    CALCULATE(
        CurrentDate,
        DimDates[Year] = YEAR(CurrentDate) - 1,
        WEEKNUM(DimDates[Date]) = CurrentWeek,
        WEEKDAY(DimDates[Date]) = CurrentDayOfWeek
    )
RETURN
    CALCULATE(
        [Items Produced],
        DimDates[Date] = LastYearDate
    )
 
But, you need to have this:
SalesSameWeekDayLastYear =
VAR CurrentDate = MAX('Calendar'[Date])
VAR CurrentWeek = WEEKNUM(CurrentDate)
VAR CurrentDayOfWeek = WEEKDAY(CurrentDate)
VAR LastYearDate =
    CALCULATE(
        MAX('Calendar'[Date]),
        'Calendar'[Year] = YEAR(CurrentDate) - 1,
        WEEKNUM('Calendar'[Date]) = CurrentWeek,
        WEEKDAY('Calendar'[Date]) = CurrentDayOfWeek
    )
RETURN
    CALCULATE(
        [Sales],
        'Calendar'[Date] = LastYearDate
    )
 
They produce different results and the one I provided works 🙂




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Got it, thanks so much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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