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
nbs333
Frequent Visitor

Total Revenue previous year week/day

I want to write a measure that returns the total revenue for the previous year's week number and day number.

 

For example, 1/1/2021  is the first week of the year and is on a friday so the value would be 1-6. I would like the total revenue for the previous years value for 1-6, which in this example is 1/3/2020.

 

In my date table I have a column the concatinates the week and day number so I can filter my date. 

 

The mesure below returns the date for the previous years week-day#

PY Week-Day # = 
    CALCULATE(
        MAX(Dates[Date]), 
        FILTER(
            ALL(Dates),
            Dates[Date] < MAX(Dates[Date])), 
            VALUES(Dates[Week-Day Number])
        )

 

I tried writing a measure to return total revenue based on the date measure above but it returns blank. Here is my attempt:

PY Week-Day Revenue = 
    CALCULATE(
        SUM(Orders[pricing]),
        FILTER(All(Dates),
            Dates[Date]
                = [PY Week-Day #]
        )
    )  

I'm not sure what I am doing wrong. Any help figuring this out is greatly appreciated.

 

1 REPLY 1
amitchandak
Super User
Super User

@nbs333 , usually same week last year is 364 days behind

week Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-364,DAY))

 

Or you can these columns in date table and try meausres like

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

measures
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Last year Week= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))

 

This week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Week] = Max('Date'[Week]) ))
Last year same week= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Week] = Max('Date'[Week])))

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.