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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rile14
Helper I
Helper I

Limiting x-axis in the Clustered Column chart

Hi All,

 

Currently, I have a chart like this:

rile14_0-1649160421852.png

Is it possible to have a chart showing years on the x-axis 5 years prior and 5 years after the year where I have data? I need that to be dynamic based on the selection.

 

To make it more simple, I need output like this:

rile14_1-1649160563548.png

So, if I had data available for 1990 for example I would like to see that data displayed with a bar, and 1985 and 1995 displayed on the x-axis, together with 1990.

 

 

Thanks.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @rile14 ,

I created some data:

vyangliumsft_0-1649917747446.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _1=CALCULATE(MAX('Table'[year]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[amount]<>BLANK()))
var _table=FILTER(ALL('Table'),'Table'[amount]<>BLANK())
return
IF(
MAX('Table'[year]) in SELECTCOLUMNS(_table,"1",[year])|| MAX('Table'[year]) in SELECTCOLUMNS(_table,"1",[year] +5)|| MAX('Table'[year]) in SELECTCOLUMNS(_table,"1",[year] -5),1,0)

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1649917747447.png

3.  Result:

vyangliumsft_2-1649917747450.png

 

Please click here for the pbix file

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @rile14 ,

I created some data:

vyangliumsft_0-1649917747446.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _1=CALCULATE(MAX('Table'[year]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[amount]<>BLANK()))
var _table=FILTER(ALL('Table'),'Table'[amount]<>BLANK())
return
IF(
MAX('Table'[year]) in SELECTCOLUMNS(_table,"1",[year])|| MAX('Table'[year]) in SELECTCOLUMNS(_table,"1",[year] +5)|| MAX('Table'[year]) in SELECTCOLUMNS(_table,"1",[year] -5),1,0)

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1649917747447.png

3.  Result:

vyangliumsft_2-1649917747450.png

 

Please click here for the pbix file

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

rile14
Helper I
Helper I

Hi Liu,

 

Thanks for your response. It seems that you didn't understand my requirement. Sorry if I explained that bad.

This is the visual that I currently have:

rile14_0-1649670916339.png

The expected output would be to have 5 year periods shown on the x-axis starting from 1975 until 2010 (including 2010),  even though there is no data for 1975 and 2010. So this would be the result:

rile14_1-1649671049859.png

 

Is this possible? 

Thanks.

Anonymous
Not applicable

Hi  @rile14 ,

I created some data:

vyangliumsft_0-1649400540748.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
DISTINCT('Table'[Year])

vyangliumsft_1-1649400540749.png

2. Create measure.

Flag =
var _select=SELECTEDVALUE('Table 2'[Year])
return
IF(
    YEAR(MAX('Table'[Date]))>=_select-5&&YEAR(MAX('Table'[Date]))<=_select+5,1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1649400540750.png

4. Result:

vyangliumsft_3-1649400540751.png

Please click here for the pbix file

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.