Reply
Highlighted
Member
Posts: 336
Registered: ‎03-17-2016
Accepted Solution

How can I sort the text values in a filter object?

Untitled.png???


Accepted Solutions
Member
Posts: 114
Registered: ‎12-14-2015

Re: How can I sort the text values in a filter object?

Hi @vitexo87,

 

   as @meysun said you have to use "Sort By Column".

 

1) You have to create two calculated columns ("monthName" and "monthNumber") and visualize monthName as a filter.

 

sortFilterMonths (1).png

 

2) After that you have to select "Sort By Column" and sort by monthNumber, and you gain the result.

 

sortFilterMonths (2).png

Let Me Know If It Works.

 

#I'M Not An Expert#

View solution in original post


All Replies
Power BI Team
Posts: 96
Registered: ‎07-24-2015

Re: How can I sort the text values in a filter object?

Established Member
Posts: 248
Registered: ‎03-02-2016

Re: How can I sort the text values in a filter object?

Based on your description, you would like to sort text values in the Slicer control. You can click the (...) part to to select Sort By to sort the slicer alphabetically by text values in the slicer.

 

Slicer Sort.png

Member
Posts: 336
Registered: ‎03-17-2016

Re: How can I sort the text values in a filter object?

Sorry did not ask the right way, I need to create a classification of months in the filter object, eg January, February, March ..... and now I can only sort in alphabetical order

Established Member
Posts: 158
Registered: ‎01-05-2016

Re: How can I sort the text values in a filter object?

I see that you are trying to sort months chronolically.

If the user entered the months, Power BI will consider them as text and will not convert them to dates even if you tried to in the formatting section, it won't let you.

 

I found a 'not very nice' workaround to that...
Consider that the months you want to sort are in a column named 'Text'. Add a new column: Month = Table1[Text]&"-16" 
This new column will automatically take the data type date.

 

Add the new column 'Month' to an empty table, you will have the following values in the visualizations pane
Values.PNG

Remove year, quarter, and day. Only the month will stay and it will be considered as a date, that way you can sort it according to time and not alphabetically.

Then you can transform your table into a slicer and months will stay ordered.

 

I tried to extract the month directly from the new column but that didn't work.

 

If someone has a better and neater solution, please let us know.

Best!

Member
Posts: 114
Registered: ‎12-14-2015

Re: How can I sort the text values in a filter object?

Hi @vitexo87,

 

   as @meysun said you have to use "Sort By Column".

 

1) You have to create two calculated columns ("monthName" and "monthNumber") and visualize monthName as a filter.

 

sortFilterMonths (1).png

 

2) After that you have to select "Sort By Column" and sort by monthNumber, and you gain the result.

 

sortFilterMonths (2).png

Let Me Know If It Works.

 

#I'M Not An Expert#

Established Member
Posts: 158
Registered: ‎01-05-2016

Re: How can I sort the text values in a filter object?

@B129 is absolutely right.

However this only works when the initial column to sort is already of date type. Mine works when the months names are hardcoded and do not come from a date field.

 

Unfortunately, there is a lot of improvement that has to be made in data types and converting.

Member
Posts: 114
Registered: ‎12-14-2015

Re: How can I sort the text values in a filter object?

@SabineOussi I just saw your solution and I think that it's really great, I've never thought about that.

It can be very helpful!!

Established Member
Posts: 185
Registered: ‎11-15-2016

Re: How can I sort the text values in a filter object?

Thanks =D works well!!!

Frequent Visitor
Posts: 5
Registered: ‎01-19-2017

Re: How can I sort the text values in a filter object?

The solution is far easier than I thought. 

 

Steps

  1. In the "Fields" pane, click on the field that is being dispalyed.
  2. On the "Modeling" tab, click "Sort By Column".
  3. Chose the column that you want to sort the displayed field by.
  4. Viola