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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
DHB
Helper IV
Helper IV

Switch groups in 100% Stacked chart

I'm using a 100% Stacked chart and the legend is either Y or N.  I have the N coming up at the bottom of the bar and Y from the top.  Is there any way I can switch those two around so that Y starts at the bottom?

 

Thank you,

 

DHB

 

 

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

There sure is.  Just add a new column to your table that will control the sort order of your Legend column

 

So please add the following column 

Legend Sort = IF('mytable'[Legendcol] = 'Y' , 0 , 1 )

 

Then specify the sort order of your existing column to use this new column using the Sort By Column feature

 

Sort by mont.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

7 REPLIES 7
Phil_Seamark
Employee
Employee

There sure is.  Just add a new column to your table that will control the sort order of your Legend column

 

So please add the following column 

Legend Sort = IF('mytable'[Legendcol] = 'Y' , 0 , 1 )

 

Then specify the sort order of your existing column to use this new column using the Sort By Column feature

 

Sort by mont.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

That's great thanks Phil.

 

The issue I have now is that I can't sort another column in the same table.   It says Sort By Another Column Error - This column can't be sorted by a column that is already sorted, directly or indirectly , by this column.  Can I only do this once per table?

Oh ok, it looks like you can't then.  I haven't come across that.  I take it you have another Y/N column in your table?

 

Perhaps just create some more sorting columns (which you can hide)


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Yes, I have two Y/N columns in the same table.  Thank you for your trick for sorting one column, I'll definitely be able to use that elsewhere.

Hi @DHB,

 

As @Phil_Seamark suggested create another SortBy Column for your additional column. 

 

You can most definitely then use your additional SortBy column on your additional column.





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

Proud to be a Super User!







Power BI Blog

I've got it now.  I'd been creating sorting columns that referenced the column I wanted to sort.  All working perfectly.  

 

Thanks so much for your help.

 

DHB

Hi @GilbertQ,

 

I tried sorting the two columns with seperate SortBy columns but PBI wasn't happy with it.  I'll give it another try tomorrow.

 

Thanks,

 

DHB

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors