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! Learn more
Hi,
I have a data table like below where i'd like to select a date in a slicer and calculate Year over Year sales.
Slicer has 3 date options. Last Year, Last Month and Year to date and it is based on "Slicer Date" column in the table.
I created measure TY: = Calculate(SUM('P&L'[Values]), ALLSELECTED('P&L'[Slicer Dates]))
| Calendar Year | P&L | Values | Slicer Date |
| 12/31/2020 | Sales | 1000 | |
| 12/31/2021 | Sales | 2000 | Last Year |
| 1/1/2021 | Sales | 3000 | |
| 1/1/2022 | Sales | 4000 | Last Month |
| 1/31/2021 | Sales | 5000 | |
| 1/31/2022 | Sales | 2500 | YTD |
You have to put closing bracket at the end
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
@mh2587 when i added that bracket it worked however it removed all filters in the dashboard and returning wrong values.
My original TY formula works the challange is when a slicer selected i can't get Last year [LY} formula to work.
The way i am reading is when i select YTD it pulls sales for YTD 2022 but i cant get YTD 2021 and calculate YoY Chg. This issue is with [LY] formula. Please note Slicer Date column i added later on to the table based on values in Calendar Year.
Hope this helps clarify.
Thanks
TY: = Calculate(SUM('P&L'[Values]), ALLEXCEPT('P&L'[Slicer Dates]))
change all to allexcept
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
@mh2587 New formula returned below error message and screenshot
The syntax for '(' is incorrect. (DAX(Calculate(SUM('P&L'[Values]), ALLEXCEPT('P&L'(Slicer Dates])))).
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.