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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
waslinko
Frequent Visitor

YTD of Previous Year

I am trying to create a DAX measure that returns the total revenue of the previous year (2024) but only the data up until 

certain date of this year (2025).

 

I have an excel file that has all the sales data of the current year (2025) and another excel file with the sales data of (2024). 

I created a measure that calulculates the total revenue from my 2025 table. (the only sales data I have is for the month of January, as it is still only the first month in 2025)

Total Revenue = SUM(2025[Revenue])

 

This sales data only has data up until the previous day, as it does not refresh until the next day. (not totally relevant, but I also have a measure that calculates the daily revenue of the previous day, which should automatically update as the days continue, so YTD would be Jan 1st - Jan 14th) 

Daily Revenue = 
CALCULATE(
SUM(2025[Revenue]),
'Calendar'[Date] = TODAY()-1)

 

What I am looking for is to calculate the total revenue from my 2024 table that is the year to date of this year, but showing sales data from the 2024 year. Meaning I want a DAX measure that gives me the sales data of 2024 with the dates of Jan 1st - Jan 14th, but have it automatically update as the days go on in this year (the next days sales data info would be Jan 1st -Jan 15th but for 2024), similar to my daily revenue DAX measure. 

 

I've used DAX measures such as the one below to create this calculation, but is there another way that doesn't require me to update the DATESBETWEEN field each time a new day occurs?

2024 Revenue YTD = 
CALCULATE(
[2024 Revenue],
DATESBETWEEN(
'2024'[Date],
DATE(2024, 1, 1),
DATE(2024, 1, 14)))

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @waslinko ,

 

I suggest you to try code as below to create a measure.

2024 Revenue YTD =
VAR _RANGESTART =
    DATE ( 2024, 1, 1 )
VAR _RANGEEND =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) - 1 )
RETURN
    CALCULATE (
        [2024 Revenue],
        DATESBETWEEN ( '2024'[Date], _RANGESTART, _RANGEEND )
    )

Result is as below.

vrzhoumsft_0-1736991820314.png

 

You can download my attachment to learn more details.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
DAXian
Frequent Visitor

Try this for year-to-date : 

2025 Revenue YTD =
 CALCULATE(
[2024 Revenue],
DATESYTD('Calendar'[Date])
)

And this one for Previous Year :

2024 Revenue YTD = CALCULATE(
[2024 Revenue],
  Dateadd(DATESYTD('Calendar'[Date]),-1,Year)
)

But I would suggest to rename 2024 Revenue YTD to PY Revenue as this is dynamic. it will calculate the previous year, say if you are in other years too (i.e.  if in 2023, PY is 2022)

Anonymous
Not applicable

Hi @waslinko ,

 

I suggest you to try code as below to create a measure.

2024 Revenue YTD =
VAR _RANGESTART =
    DATE ( 2024, 1, 1 )
VAR _RANGEEND =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) - 1 )
RETURN
    CALCULATE (
        [2024 Revenue],
        DATESBETWEEN ( '2024'[Date], _RANGESTART, _RANGEEND )
    )

Result is as below.

vrzhoumsft_0-1736991820314.png

 

You can download my attachment to learn more details.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi i have a similar issue-goal is sales from prior year only through end of prior day this year

Measure 1Measure 2YTD YOY-through yesterdaySales Order Date Last year Sales Order Date Present Year
LY SalesPY Sales 2024(leap year)2025

This worked, thank you!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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