Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi All,
My DAX for PYTD is giving me issues. I have to change the day (e.g. 372 at end of formula) every few months because the number of selling days is different this year from last year. I'd like a permanent solution if possible.
Solved! Go to Solution.
@Anonymous , you can try measures like
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD("Date"[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd("Date"[Date],-1,Year),"12/31"))
or like these
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd("Date"[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR("Date"[Date]))
Hi @Anonymous ,
If your dates are contiguous,you could use "DATEADD" or "SAMEPERIODLASTYEAR",otherwise create a date table first.
Then you could use below fomular:
PYTD = CALCULATE(SUM('Table'[Value]),SAMEPERIODLASTYEAR('Table'[Date]))
Or:
PYTD1 = CALCULATE(SUM('Table'[Value]),DATEADD('Table'[Date],-1,YEAR))
And you will see:
For the related .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my reply as a solution!
Hi @Anonymous ,
If your dates are contiguous,you could use "DATEADD" or "SAMEPERIODLASTYEAR",otherwise create a date table first.
Then you could use below fomular:
PYTD = CALCULATE(SUM('Table'[Value]),SAMEPERIODLASTYEAR('Table'[Date]))
Or:
PYTD1 = CALCULATE(SUM('Table'[Value]),DATEADD('Table'[Date],-1,YEAR))
And you will see:
For the related .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my reply as a solution!
@Anonymous , you can try measures like
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD("Date"[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd("Date"[Date],-1,Year),"12/31"))
or like these
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd("Date"[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR("Date"[Date]))
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 98 | |
| 72 | |
| 50 | |
| 50 | |
| 43 |