Help sorting a text column by index value

I have a table:
<Table%20A

I want to visualize the data by ATTRIBUTE. I created an INDEX to sort the text field. This is the view I want.
Visual%20A

But when I remove the INDEX, the table looks like this:
Visual%20B

I’m sure the solution is simple, but I cannot figure it out.

Any suggestions?

@rizzotony,

Welcome to the forum!

Really quick fix here:

Step one: in the Data View click on the Attribute column

image

Step two: under Column Tools, click on Sort by Column and choose Index

image

This will keep your Attribute column properly sorted, whether you have index in the table visual or not.

image

1 Like

Thank you, Brian!

What is tripping me up with your solution is the ATTRIBUTE column has identical values.
Table%20A
When I go to sort by INDEX, I receive an error message.
Error%201

Will I have to create multiple tables by BRANCH to achieve the result I’m looking for without showing INDEX in the visual?
Visual%20A

@rizzotony,

No, we can definitely get this to work within one table without the index in the visual.

Can you please post your PBIX file? I’ve got two different ideas on how best to handle this, and I want to test which one works better on your data.

Thanks.

  • Brian

Hi @rizzotony.

For Custom Sorting, I always prefer to use a MasterSort Table. Based on your data, I have created a new Table as below. (You can also create this table manually with Index 1,2,3 using Enter Data or DAX)

SortAttributeTable = 
SUMMARIZECOLUMNS (
    'DataTable'[ Attribute],
    "SortIndex", SUM ( 'DataTable'[Index] )
) 

In Master table, we can Sort Attribute Column by SortIndex and use it in our Visuals.PF sample PBIX file attached. Let me know in case of any queries.

Solution - rizzotony.pbix (28.2 KB)

Thanks
Ankit Jain

3 Likes

@ankit,

Nice. I was working this using CONCATENATE() to create the sort index in a calculated column in the Data table, but I like your approach better- cleaner and simpler.

  • Brian

@ankit & @BrianJ -

THANK YOU! Such a simple solution that has wide application.

Tony

1 Like