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
Anonymous
Not applicable

Re-ordering Data Labels

I am using a couple graphs to show Attendance, the labels are either 'yes' or 'no'. 

The 'no' is above the 'yes' label, how do I re-order this so that 'yes' comes first and above the 'no'? 

 

 

CapturePowerBI.PNG

15 REPLIES 15
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please let us know whether @Daviejoe 's method is helpful.

 

If it is, please accept his reply as solution to your question so that people who may have the same question can get the solution directly.

 

If not, please give us more details.

 

 

Best Regards,

Icey

Daviejoe
Memorable Member
Memorable Member

You can add an Index column which will have Yes as 1 and No as 2.

 

Then sort your legend column by the index column, Yes will now be above No.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , If they are legends. Is create then create a sort column like this

 

show Attendance 1 = [show Attendance]

show Attendance sort = if([show Attendance],"Yes",1,0)

 

Sort show Attendance 1 on show Attendance sort.

 

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

Anonymous
Not applicable

Thanks for your repluy. Can you explain exactly the formula to use? 

The column I'm pulling from is 'Attended?' and the options are 'yes' and 'no'

Sorcha17_0-1601972076257.png

 

I went to the Add Column tab, highlighted the Attended column and then selected Add Columns from Examples,  I then entered a 1 against the rows that had a Yes and a 2 against those that have a No.

 

The Query Editor is smart so it applies this pretty quickly to the whole column.

 

You then order your Legend column by the newly created Index column.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you, I added in the new sort column with Yes=1, No-2. 

 

Where can I find the legend order to change? 

 

Is it different to the 'sort by' option because that does not re-order the legend. 

 

Sorcha17_0-1602087289639.png

 

If you follow the below steps, then the legend should sort of its own accord.

 

Go to your table of data and follow the steps

 

Legend Order.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

There is no data in my data tables, I pulled straight from excel into the graphs and havent used the data tables. I did the sort by anyway to see if it would work and it didnt.

 

Sorcha17_0-1602242416050.png

 

Hi @Anonymous 

 

I'm not sure why the data isn't pulling into your Power BI Model, once the data comes into the model and you sort the Yes/No column by the Column Index then it should work as we've mapped out previously.

 

Once you get your data pulling into your report then it should work.

 

Have you changed anything in your data model to make the data not pull through?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Not that I am aware of! 

 

When I'm creating a new visual I click on the 'get data' tab and link to the excel I want to use. I don't think I've ever seen any data in those tables 

 

Sorcha17_0-1602758337020.png

 

Once you have pulled in your data from your Excel file you can Transform the data in the Query Editor

 

Here is a useful link

 

https://radacad.com/sort-a-column-with-a-custom-order-in-power-bi





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Yeah I transform the data anytime I pull in from a new spreadsheet and in the Query Editor it shows as this table. This is where I added the Sort column. 

Sorcha17_0-1602759300655.png

 

I'd also remove blank rows as the top line appears to show all Null values





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




And your data is not showing once you've closed and applied your changes in the Query Editor?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

No it doesn't show in the 'data' tab on the left but it works perfectly in the 'report' view.  I apply any edits I make in the query editor and they all work fine too

Sorcha17_0-1602763406265.png

 

 

 

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.