Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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)))
Solved! Go to Solution.
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.
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.
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)
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.
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 1 | Measure 2 | YTD YOY-through yesterday | Sales Order Date Last year | Sales Order Date Present Year |
LY Sales | PY Sales | 2024(leap year) | 2025 |
This worked, thank you!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |