March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi everyone,
I would like to compare the same period of the current year and the prior year (example YTD march 23 - march 22).
Can I use the function PREVIOUSYEAR?
And how ?
Thanks in advanced.
@vr83 if the answer is correct, I ask you to accept it as a solution, otherwise I am available for further clarification.
BBF
@vr83 Hi!
Yes, you can use the PREVIOUSYEAR function in DAX to compare the same period of the current year and the prior year. Here is an example formula that you can use to achieve this:
YTD Prior Year =
CALCULATE(
[Total Sales],
PREVIOUSYEAR(Dates[Date]) <= Dates[Date] &&
YEAR(PREVIOUSYEAR(Dates[Date])) = YEAR(MAX(Dates[Date]))
)
The calculation is based on the following conditions:
You will need to replace [Total Sales]
with your own measure and Dates[Date]
with your own date column.
BBF
homestly I don't know why it doesn't work.
Probably because my record are maybe different.
So in this case how can I write the correct formula using what you've write?
YTD Prior Year =
CALCULATE(
[Total Sales],
PREVIOUSYEAR(Dates[Date]) <= Dates[Date] &&
YEAR(PREVIOUSYEAR(Dates[Date])) = YEAR(MAX(Dates[Date]))
)
Thansk
@vr83 Firstly, you have to create a column with only the Year and one with only the Month:
Hi,
I've tried the formula but it doesn't work...
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
24 | |
21 | |
20 | |
15 | |
10 |