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
Simone2004
Helper I
Helper I

Order by Hierarchy Date by year descending and month number ascending

Hi everyone,

I have more than one problem I couldnt resolve by myself.

 

I have this matrix:

Simone2004_0-1619593871690.png

I would like to order by default year descending (2021, 2020, ...) but quarters and month ascending (1, 2, 3, ...)

I have tryed to modifythe query. I clicked on transform data: 

Simone2004_1-1619594141694.png

 

And I ordered the table as I would like to have

Simone2004_0-1619594315849.png

The registry dimension_time is related to payment fact.

 

That was my first problem. Second one:

 

I would like to replace month number with month name. I have created a new column in this way:

 ```

month_name = SWITCH (
'registry dimension_time'[month],
1, "Jan",
2, "Feb",
3, "Mar",
4, "Apr",
5, "May",
6, "Jun",
7, "Jul",
8, "Aug",
9, "Sep",
10, "Oct",
11, "Nov",
12, "Dec",
BLANK ()
)

```

In my date hierarchy I have replace month with my new column month_name:

Simone2004_1-1619594815010.png

But now it order month by name:

Simone2004_2-1619594926736.png

 

Any idea how can I solve this other problem?

 

 

Last thing....  I am using direct query, not import.

 

Thank you

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Simone2004 ,

 

For your first problem, try this:

 

Put column [Year] into "Rows" field and sort descending. Then put [Quarter] and [Month] columns into "Rows" field and you'll get what you want.

 

sort.gif

 

 

For your second problem, it is needed to sort [month_name] column by [month] column like so:

sort by column.PNG

 

 

 

Best Regards,

Icey

 

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

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Simone2004 ,

 

For your first problem, try this:

 

Put column [Year] into "Rows" field and sort descending. Then put [Quarter] and [Month] columns into "Rows" field and you'll get what you want.

 

sort.gif

 

 

For your second problem, it is needed to sort [month_name] column by [month] column like so:

sort by column.PNG

 

 

 

Best Regards,

Icey

 

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

amitchandak
Super User
Super User

@Simone2004 , For that you create a desc sort column for year

new columns

year 1 = [year]

year sort = rankx('Date', [Year],,desc,dense)

 

Mark Year Sort as sort column for year 1 and use year 1 in your visual

How to Create Sort Column and Solve Related Errors: https://youtu.be/KK1zu4MBb-c

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.