This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi all, I would like to filter sales of the current year.
Following function perfectly does the job (I know there are more elegant ways to do this 😉 😞
Solved! Go to Solution.
Try datesytd or totalytd with calendar table. try
sales_year =
var _year = YEAR(maxx('sales_table','sales_table'[date]))
CALCULATE(SUM('sales_table'[sales]);
FILTER('sales_table';YEAR('sales_table'[date]) =_year ) ))
Or
sales_year =
var _year = YEAR(maxx('sales_table','sales_table'[date]))
CALCULATE(SUM('sales_table'[sales]);all('sales_table'[date]);
FILTER('sales_table';YEAR('sales_table'[date]) =_year ) ))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
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"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
Try
@Anonymous
Basically, Lastdate() and lastnoblank() for date/time columns return a table containing a single column and single row with a date value. Max() returns a value, although both return the same date. I think this the difference causing the difference when using them in filters.
https://docs.microsoft.com/en-us/dax/max-function-dax
https://docs.microsoft.com/en-us/dax/lastdate-function-dax
https://docs.microsoft.com/en-us/dax/lastnonblank-function-dax
Best,
Paul
Try datesytd or totalytd with calendar table. try
sales_year =
var _year = YEAR(maxx('sales_table','sales_table'[date]))
CALCULATE(SUM('sales_table'[sales]);
FILTER('sales_table';YEAR('sales_table'[date]) =_year ) ))
Or
sales_year =
var _year = YEAR(maxx('sales_table','sales_table'[date]))
CALCULATE(SUM('sales_table'[sales]);all('sales_table'[date]);
FILTER('sales_table';YEAR('sales_table'[date]) =_year ) ))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
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"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
Try
Perfect thanks, I added a return statement and this does the job! Thanks again!
sales_year =
var _year = YEAR(maxx('sales_table','sales_table'[date]))
RETURN
CALCULATE(SUM('sales_table'[sales]);all('sales_table'[date]);
FILTER('sales_table';YEAR('sales_table'[date]) =_year ) ))
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 35 | |
| 32 | |
| 26 | |
| 21 | |
| 18 |
| User | Count |
|---|---|
| 68 | |
| 36 | |
| 32 | |
| 25 | |
| 23 |