Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
So i have data from 1st jan 2021 to 1st June 2023. I am able to calcuate the Total YTD for current year that is 1st jan 2023 to 1st june 2023. Now i want previous years values but not for the entire year but for the time period 1st jan to 1st jun 2022 (The same period which is of my current year).
Any suggestions ?
Solved! Go to Solution.
HI @UditJ,
You can extract the current date and use date function to get the previous date value as condition to calculate.
LYTD =
VAR currDate =
MAX ( Table1[Date] )
VAR prevDate =
DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
RETURN
CALCULATE (
SUM ( Table1[Sales] ),
FILTER (
ALLSELECTED ( Table1 ),
YEAR ( [Date] ) = YEAR ( prevDate )
&& [Date] <= prevDate
),
VALUE ( Table1[Category] )
)
Regards,
Xiaoxin Sheng
HI @UditJ,
You can extract the current date and use date function to get the previous date value as condition to calculate.
LYTD =
VAR currDate =
MAX ( Table1[Date] )
VAR prevDate =
DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
RETURN
CALCULATE (
SUM ( Table1[Sales] ),
FILTER (
ALLSELECTED ( Table1 ),
YEAR ( [Date] ) = YEAR ( prevDate )
&& [Date] <= prevDate
),
VALUE ( Table1[Category] )
)
Regards,
Xiaoxin Sheng
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 30 | |
| 28 |
| User | Count |
|---|---|
| 128 | |
| 88 | |
| 79 | |
| 67 | |
| 62 |