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
JayVee
Frequent Visitor

Show every month of the year in the x-axis independent of slicer selection

Hi All,

 

How can I create a chart where the x-axis shows all the months of the selected year (e.g. 2021) even when the month slicer is active?

 

axis-april.pngaxis-may.png

 

In the image above I have the result I want, and in the image below is what I actually get from PowerBI when selecting different months from the date slicer:

 

axis-april-wrong.pngaxis-may-wrong.png

 

Note that in this case I'm using a DATESYTD approach to calculate the monthly aggregates and I have already created an independent date table so that all months are displayed independent of the selected slicer.

 

However, it's only showing the months included in the DATESYTD and I can't find a way to include all the missing months from that year even when tring to filter the data with other functions like ENDOFYEAR or [Date]=MAX([Year]):

 

axis-may-sliced.png

 

Many thanks! Jay

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @JayVee ,

I created some data:

vyangliumsft_5-1651220719977.png

Here are the steps you can follow:

1. Create a calendar table as a slicer.

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

vyangliumsft_6-1651220719978.png

2. Create measure.

Flag =
var _selectyear=
SELECTEDVALUE('Table 2'[Date].[Year]) in VALUES('Table'[Date].[Year])
return
IF(
ISFILTERED('Table 2'[Date].[Year]),IF(_selectyear,1,0),1
)
Amount =
if(SELECTEDVALUE('Table'[Date].[Month]) IN VALUES('Table 2'[Date].[Month]),   SUM('Table'[rand]),0)

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

vyangliumsft_7-1651220719978.png

4. Result:

vyangliumsft_8-1651220719983.png

 

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

5 REPLIES 5
Anonymous
Not applicable

Hi  @JayVee ,

I created some data:

vyangliumsft_5-1651220719977.png

Here are the steps you can follow:

1. Create a calendar table as a slicer.

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

vyangliumsft_6-1651220719978.png

2. Create measure.

Flag =
var _selectyear=
SELECTEDVALUE('Table 2'[Date].[Year]) in VALUES('Table'[Date].[Year])
return
IF(
ISFILTERED('Table 2'[Date].[Year]),IF(_selectyear,1,0),1
)
Amount =
if(SELECTEDVALUE('Table'[Date].[Month]) IN VALUES('Table 2'[Date].[Month]),   SUM('Table'[rand]),0)

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

vyangliumsft_7-1651220719978.png

4. Result:

vyangliumsft_8-1651220719983.png

 

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

Hi @Anonymous ,

 

Thats exactly it! I have updated the measure to take into account all the months previous to the Single Selection in the slicer and it worked perfectly!

 

image.png

I just had to create another calculated column with the month number and then include the <= operator in the measure formula:

Amount = IF(
            SELECTEDVALUE('Table'[Month Number]) <= VALUES('Table 2'[Month Number]),
            SUM('Table'[rand]),
            0
           )

 

Great job and many thanks for that!

JayVee
Frequent Visitor

To help further, here is a sample of the data as well as the PBIX where I try to solve this point:

PBIX file

CSV file

 

amitchandak
Super User
Super User

@JayVee , Try to add +0 to you measure or

 

use this option

 

ShowItemwithoutdata.JPG

 

if need check

Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

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

Hi @amitchandak ,

 

That would work if the next months didn't contain any data. However, they are fully populated already as you can see in the image below for when I select "December" in the slicer:

 

JayVee_0-1650974295822.png

 

What I want to do is kind of "filter out" some of these months based on the slicer, but still showing the full x-axis even for the months which will be now filtered out. That would result in the picture of the first post:

 

axis-may.png

 

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.