Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
bencefarsang
New Member

How to calculate the "range of years" in a column chart "range by years"? (illustration included)

Dear Power BI Community,

My question will be a little odd, but please bear with me. I have 3 years stored as numbers: 2019, 2020, and 2021. And I would like to calculate the total range of years / total number of years and visualize it on a column chart. In this case, the range of years is "3 years". 

 

Here's the measure to calculate the range of years:

range = MAX(Data[year]) - MIN(Data[year]) + 1
(range = 2021 - 2019 + 1 = 3)

However, when I visualize the range by years, I get the following chart:
pbi.PNG
But I would like to have a chart like this:
pbi2.PNG
You can see that I would like to have the value "3" by every year, instead of the "1" values. I understand that my way of thinking is false here. I would like to visualize the total number of years and show this same global value by every year on a column chart.

Can you help me please, how can I get the total number of years by every year? Any other solution would be more than welcomed.

Thank you in advance.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@bencefarsang , Try like

 

range = calculate(MAX(Data[year]) - MIN(Data[year]) + 1, all(Data[year]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@bencefarsang , Try like

 

range = calculate(MAX(Data[year]) - MIN(Data[year]) + 1, all(Data[year]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you Sir for the solution and the fast respond!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.