Forum Discussion
Return Current Year Only
I need this to return Current year only. Also if I could get a separate means to return previous year only in a different measure. I am stuck and have searched all over for a solution.
Hi, bstark1287
You can try the following methods.
Column:Month = FORMAT([Date],"mmmm")Measure:
Current Year = CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Calendar' ), [Month] = SELECTEDVALUE ( 'Calendar'[Month] ) && YEAR ( [Date] ) = YEAR ( TODAY () ) ) )Previous year = CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Calendar' ), [Month] = SELECTEDVALUE ( 'Calendar'[Month] ) && YEAR ( [Date] ) = YEAR ( TODAY () ) - 1 ) )Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
7 Replies
- parry2kSuper User
bstark1287 Are you getting blank values? Do your Calendar dimension have dates in the future?
✨ Follow us on LinkedIn and to our YouTube channel
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.
- bstark1287Helper II
I am receiving values for all dates. My calendar has dates up to 2 years in the future. I would like to return only ORDER_QTY for current year in this measure, then an additional measure to return only previous year. End result should be two lines, one for current year another for previous year.
Current results:
Desired results would look similar to this:
- v-zhangtiCommunity Support
Hi, bstark1287
You can try the following methods.
Column:Month = FORMAT([Date],"mmmm")Measure:
Current Year = CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Calendar' ), [Month] = SELECTEDVALUE ( 'Calendar'[Month] ) && YEAR ( [Date] ) = YEAR ( TODAY () ) ) )Previous year = CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Calendar' ), [Month] = SELECTEDVALUE ( 'Calendar'[Month] ) && YEAR ( [Date] ) = YEAR ( TODAY () ) - 1 ) )Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- parry2kSuper User
bstark1287 check out this video on my YT channel New Year and my MTD and QTD measures stopped working, why? - Power BI - YouTube that talks about when you have dates in the future and how to work with current year only or based on the last transaction date.
✨ Follow us on LinkedIn and to our YouTube channel
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.
- bstark1287Helper II
It is not that my YTD measure isn't working. As you can see from my "current results" example it is working great. I want to limit that result down to current year only, then create a second measure for previous year only. I have to do this in a measure as opposed to a filter because the next requirement is for a dynamic visual to report by order creation date. If you can help me with this I would greatly appreciate it! I have already followed your Linkedin and youtube channel as thanks for your response this far.
- parry2kSuper User
bstark1287 you can easily use the relative date filter to filter for 2 years, put the month column on the x-axis, year on legend, and measure on value.
Use a relative date slicer or filter in Power BI - Power BI | Microsoft Learn
✨ Follow us on LinkedIn and to our YouTube channel
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.
- bstark1287Helper II
Thank you for your responses! Unfortunately it has to be in the dax of the measure as I am trying to create a dynamic slicer that only affects the visual using the measures. So once the measure is selected to only OB YTD Ship CY & OB YTD Ship PY it can then be changed to visualize OB YTD Created CY & OB YTD Created PY. The requirements are for only one visual that can show both so if I can figure out the DAX I can get it to work. PS your YouTube tutorials are great! I will be spending some time on your channel.