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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BDibuz
Regular Visitor

Sorting the x-axis with "YYYYWW" data

I have a set of data where for each [YYYYWW], there is a [utilization %] value (there are 3 "locations" (sets) in the legend, but this shouldn't affect the x-axis). The [YYYYWW] is a column formatted as: 

 

YearWeek = INT([Yr]&Format([Wk],"00")) 

This gives the correct format. I have it set to whole number for the data type. However, as seen in the picture below, the ordering is incorrect and seems arbitrary. image.png

If I set the x-axis type to "continuous", it seems to order them correctly, but then it leaves a large gap for the transition between 201752 and 201801. Whats the best way to format this so that it orders them correctly, but doesn't leave a gap?image.png

 

 

 

 

1 ACCEPTED SOLUTION

 

The sorting as text will work as you have created a proper yearweek value. 

The data type should be text.

X axis type: categorical

Sort Visual by yearweek. 

 

Similar example: You see that I do not have a gap between 200812 and 200901...

 

Capture.PNG

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

View solution in original post

7 REPLIES 7
waltheed
Solution Supplier
Solution Supplier

Hi BDibuz, 

 

You need to change the x-axis property of the chart, called Type. Change it from Continuous to Categorical. Then it should look OK. 

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

Thanks for the response; however, to clarify, the first image in my post is what happens when it is set to "categorical". It displays the x-axis values in a random order. I have also gone to the Modeling tab and selected Sort by Column - > YearWeek. This doesn't help. 

Oh, and you should also change it to type Text instead of whole number. And sort the Visual by the YearWeek column.

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

Unfortunately, this still doesn't give the correct ordering (I also worry that this would result in lexicographical ordering instead of numerical). Maybe this sample set of the source table will help determine why:image.png

The plot is set up as such:

 

image.png

 

 

The sorting as text will work as you have created a proper yearweek value. 

The data type should be text.

X axis type: categorical

Sort Visual by yearweek. 

 

Similar example: You see that I do not have a gap between 200812 and 200901...

 

Capture.PNG

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

Ok, I got this to work. I think the last piece of the puzzle was using the sorting selector in the visual and not in the Modeling tab. Thank you

Good to hear that it worked for you! Thanks. 

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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