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
DavidWaters100
Post Patron
Post Patron

Cannot sort by user selected month when axis is only month number

Hi,

 

I have two rolling 12 measures for this year and one for last year and it is working per below but the major problem is that because the axis is just the month number without reference to the year, I cannot sort it by the month the user has selected.  In the case below the user has select April 2020.  So orange is April 2020 and dark blue is April 2019.  For May the values are dark blue is May 2019 and light blue May 2018.

 

So I need April 2020 to be first (or last) depending on the sort order.  I can only use the month number because adding the year to the axis means the columns seperate out chonologically.

 

I have run out of ideas!  Anyone got a magic workaround?

 

many thanks!

 

David

 

 example graph.PNG

Proud to be a Super User!
1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @DavidWaters100 ,

 

1. We need to create a new parameter to be a slicer.

 

cannot 1.jpg

 

cannot 2.jpg

 

cannot 3.jpg

 

2. Then we can create a measure to sort the Month.

 

Sort = 
RANKX (
    GENERATESERIES ( 1, 12 ),
    IF ( [Value] <= [SelectMonth Value], [Value] + 12, [Value] ),
    IF (
        MIN ( 'Table'[Month] ) <= [SelectMonth Value],
        MIN ( 'Table'[Month] ) + 12,
        MIN ( 'Table'[Month] )
    ),
    DESC,
    DENSE
)

 

3. At last we can create a clustered column chart, and put the [sort] to Tooltips. And change the X axis type to Categorical. We can get the result like this,

 

cannot 4.jpg

 

cannot 5.jpg

 

cannot 6.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

 

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

4 REPLIES 4
v-zhenbw-msft
Community Support
Community Support

Hi @DavidWaters100 ,

 

1. We need to create a new parameter to be a slicer.

 

cannot 1.jpg

 

cannot 2.jpg

 

cannot 3.jpg

 

2. Then we can create a measure to sort the Month.

 

Sort = 
RANKX (
    GENERATESERIES ( 1, 12 ),
    IF ( [Value] <= [SelectMonth Value], [Value] + 12, [Value] ),
    IF (
        MIN ( 'Table'[Month] ) <= [SelectMonth Value],
        MIN ( 'Table'[Month] ) + 12,
        MIN ( 'Table'[Month] )
    ),
    DESC,
    DENSE
)

 

3. At last we can create a clustered column chart, and put the [sort] to Tooltips. And change the X axis type to Categorical. We can get the result like this,

 

cannot 4.jpg

 

cannot 5.jpg

 

cannot 6.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

 

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

Thank you, great post!

Proud to be a Super User!
DavidWaters100
Post Patron
Post Patron

Sorry I have solved this now.

 

I added a column in my calendar table which returned the month number chosen by the user, then assigned an order decimal value on my calender table to the 12 month number of all years so that the chosen month had highest value, then the second highest was the previous month number etc. 

 

I then used LOOKUPVALUES to look up the order value and return it to my table with the graph.  I could then sort by the order value looked up.

Proud to be a Super User!

Oh dear, I have not solved this!  My calendar table was bringing in today's month, not the one selected by a user on another table!

 

I still haven't resolved this...

Proud to be a Super User!

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.