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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
VoltesDev
Helper V
Helper V

How to make column for sorting ?

Hi,

In my table I have rows values which has no sort in its data source (direct query), as below:

ColumnA
High
Medium
Low

 

So I figured I must create new column and create some sort value like this :

 

Sort = SWITCH(Table [ColumnA],
       "High",1,
       "Medium",2,
       "Low",3)

 

But if I go back to ColumnA and Set Order by this new column, I will get error saying it circular dependant.

 

How actually to create a custom sort ?

 

Thanks in advance

1 ACCEPTED SOLUTION
KNP
Super User
Super User

I prefer to do my data modelling in Power Query.

KNP_0-1638208943376.gif

Hope this helps.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

7 REPLIES 7
KNP
Super User
Super User

I prefer to do my data modelling in Power Query.

KNP_0-1638208943376.gif

Hope this helps.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Thank you this helped me. however, the data on my visualization is not showing the results from the new data arrangement.  what am I missing? 

 

Thank you

Probably best to open a new question.

You can reference this thread and tag people to get their attention. 

Replying to solved threads will often not get a response. 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

You could also key in the Sort column by modifying the Source step rather than defining a custom column (assuming the table was created in the query editor to begin with, of course).

Hi,

 

Sure, but I'm using Direct Query (which I didn't tell in this thread). So have limitation of modifying source, especially cannot add table.

 

Thanks

Hi @KNP 

 

Thanks, it works very well.

 

Jihwan_Kim
Super User
Super User

Hi,

I suggest creating a new table like below, instead of creating one column by one column.

Once the new table is created by using the below formula, then the ColumnA can be sorted by the Sort column.

 

New Table =
DATATABLE (
"ColumnA", STRING,
"Sort", INTEGER,
{
{ "High", 1 },
{ "Medium", 2 },
{ "Low", 3 }
}
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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