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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
NsHrTr
Frequent Visitor

Double X-axis with duplicates

Hello.

 

I am trying to represent a variable over weeks and I would like to state the month for each week, for which I use a double X-axis with Month and Week.

 

However, when I represent the variable over 2 different years, weeks are split into different months, as expected:

 

NsHrTr_0-1734608018694.png

 

 

Is there a way to sort the axis so that the months are in the correct order regardless of the presence of duplicate weeks?

1 ACCEPTED SOLUTION
NsHrTr
Frequent Visitor

I found the solution, initially following the approach v-yanjiang-msft stated in the following post:

https://community.fabric.microsoft.com/t5/Desktop/Add-weeknr-to-date-hierarchy/td-p/2293820

 

I created a custom date hierarchy, including Year, Month, Month Name, Week and XWeek (this is the custom order I need for my weeks, starting to order weeks from week 34 onwards). This just does not solve the issue of sorting when using a combined X-axis.

 

I sorted that out creating a custom order for months, XMonth, the same way I did for weeks. Then, I just ordered Month by XMonth, providing the desired result. This sorting method can be applied as well to Month Name:

 

NsHrTr_2-1736338391875.png

 

View solution in original post

5 REPLIES 5
NsHrTr
Frequent Visitor

I found the solution, initially following the approach v-yanjiang-msft stated in the following post:

https://community.fabric.microsoft.com/t5/Desktop/Add-weeknr-to-date-hierarchy/td-p/2293820

 

I created a custom date hierarchy, including Year, Month, Month Name, Week and XWeek (this is the custom order I need for my weeks, starting to order weeks from week 34 onwards). This just does not solve the issue of sorting when using a combined X-axis.

 

I sorted that out creating a custom order for months, XMonth, the same way I did for weeks. Then, I just ordered Month by XMonth, providing the desired result. This sorting method can be applied as well to Month Name:

 

NsHrTr_2-1736338391875.png

 

Uzi2019
Super User
Super User

Hi @NsHrTr 

 

Create one column which consist of Month & week together. then sort the value in asc orer. 

 

then sort the week column by Newly created column.

 

Monthweek = 'Calendar'[Month No]&'Calendar'[week]
 
sort your week column by using Monthweek column
 
I hope I answered your question!
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Hello Uzi2019,

and Happy New Year first!

 

Your solution seems easy to apply but I am unable to replicate as some week numbers relates to different months, and that lack of singularity prevents me to sort week number by the created measure.

 

I need to say that I am representing months and weeks from the calendar table, while measure is from facts table. This may be causing the issue.

 

Kind regards.

rajendraongole1
Super User
Super User

Hi @NsHrTr - Create a calculated column in your calendar table that combines Year, Month, and Week into a single value.

 

eg: YearMonthWeek =
FORMAT(CalendarTable[Year], "0000") & "-" &
FORMAT(CalendarTable[MonthNumber], "00") & "-" &
FORMAT(CalendarTable[WeekNumber], "00")

 

 

try this column ensures each week is uniquely identified by year and month.

In visual add YearMonthWeek as the X-axis for your chart.In the Modeling tab, select the YearMonthWeek column and ensure it is sorted by the YearMonthWeek column itself.

If you don't want the X-axis to show the composite column in your visual, create another column for display purposes

try the above steps, it works.

DisplayMonthWeek =
CalendarTable[MonthName] & " " & CalendarTable[WeekNumber]





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hello rajendraongole1

and Happy New Year first.

 

Thank you for your reply.

Trying this will represent the 2 years in a chronological order, not being able to compare 2 measures in the same week period unfortunately.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors