Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
8 | |
6 | |
5 | |
2 | |
2 |
User | Count |
---|---|
4 | |
4 | |
3 | |
3 | |
2 |