Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I am trying to name headers based on the year. I need to count work for an area for a year. in 2019 that was 2019, 2018, 2017 and 2016. now in 2020 I want the columns to be 2020, 2019, 2018, 2017. I don't want to have to rename them every year. I am using this in a stacked column chart and a matrix. Thanks for any help anyone can provide.
Hi @Anonymous,
Without being able to see your data, I can't produce specific DAX relevant to your data model, but if you want your visuals to 'roll' the last few years, I'd approach it as follows:
If I simulated the year to be 2019, the above visual would look as follows:
Another such approach could be to have the calculated column return TRUE/FALSE if the year falls inside your business logic. You could also implement with a measure rather than a calculated column, but I find this gives me more flexibility, particularly if I want to change the number of years using a what if paramater (which would allow my users to change the number of years dynamically).
Hopefully this gives you some ideas. Good luck!
Daniel
If my post helps, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Thank you for your reply. My situation is a lot more complicated because I have many columns in my table which prevent me from using calendar year as a matrix column, so I have 3 rows and 12 values, 5 of which I am trying to make dynamic headers with. I'm not sure it's possible, but I have a field in the data which has what I want to use as headers, I just don't know how to use it.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
6 | |
6 | |
3 | |
2 | |
2 |