Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi everyone,
I need a little help.
I have a pie chart where I have data for 2019, 2020 and 2021, but I'd like to return only the last 2 years based on the selected value in my slicer.
For example, if I have selected 2020 in my slicer, it would show 2019 and 2020. If I select 2021, it would show me 2020 and 2021, always considering the same period last year.
But I'm having trouble to do that.
The chart considers only my dCalendar[Year] and a simple measurement for counting: count = DISTINCTCOUNT (Table [Incident]).
Could anyone help me with this?
Solved! Go to Solution.
@Anonymous solution attached, hope this is what you are looking for, see image below
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts 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.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous solution attached, hope this is what you are looking for, see image below
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts 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.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k,
I have a problem similar to this one, I am trying to get the YTD Sales from the selected period (month and year) and the previous period (same period from the previous year). I tried the measure you have in the pbix but it did not work.
Could you help me please?
The file is this one: https://www.dropbox.com/s/tv4ar04dk6b66n5/Sales%20Power%20BI.pbix?dl=0
Thanks in advance.
Regards.
@parry2k this is exactly what I need.
I was trying to solve it thinking differently, your solution is great. Thank you!
@Anonymous got it, let me see if we can figure out something. Stay tuned!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous can you share a sample pbix file, remove sensitive information before sharing, share thru one drive/google drive.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k, I don't know if I did it correctly, but I share the link with the files:
@BA_Pete unfortunately that will not work, it will only if you are looking at the data for the current year, if you select, let's say 2018, now relative year will not work and visual will be blank because the relative year for 2018 will be -2.
But yes, if always looking at the current year and the previous year, it will work. Depends, how scalable the solution needs to be.
Just my 2 cents.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thanks @parry2k , you're absolutely right. I'll retract my previous answer to avoid confusion.
I should really brush-up on my reading skills! 🙂
Pete
Proud to be a Datanaut!
@Anonymous This is how I think it should work, you should add a date dimension in your model, there are many posts on how to do it.
Add two measures:
count = DISTINCTCOUNT (Table [Incident]) //it is pretty currently selected year
count PY = CALCULATE ( [count], SAMEPERIODLASTYEAR ( DateTable[Date] ) )
Use these two measures in the pie chart and use the year slicer from the date dimension, and you will always get to see the selected year data and the previous year data.
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts 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.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k, thank you for your answer.
I already have a date dimension in my model and that's what I'm using in this graph.
If I do it this way, creating 2 measures (count + count LY) will not work for me. I need the legend for the selected year and the previous year to be returned.
In your solution I will have the following result:
I'd like something like that, but only showing 2 years in the legend:
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
102 | |
68 | |
66 | |
54 | |
41 |
User | Count |
---|---|
161 | |
82 | |
66 | |
66 | |
61 |