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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
rashesh
Frequent Visitor

Dynamic Sorting stacked bar chart based on slicer value

I have one slicer and 3 Stacked bar charts and this bar chart contains only X-axis and legends.
In my slicer, I have values like 1,2,3,4 when I select 1 or 2, or 3 my stacked bar chart should sort according to alphabetic order but instead of these three when I select 4 My stacked bar chart has to be sorted based on legend value, not the alphabet.
Thank you in advance for whatever effort you are giving into this problem.

 

5 REPLIES 5
rashesh
Frequent Visitor

Thank you @ValtteriN for your answer but
I am sorry to not mention one thing I need to sort the legend, not the axis based on the slicer.

 

Hi,

If you want to have a dynamic legend. Then the easiest way is to use field parameters:

1. Create a new field parameter:

ValtteriN_0-1666085689486.png

(enable this in preview features)

2. Place the desired olumns:

ValtteriN_3-1666086376035.png

 

3. Now palce the parameter in legend:

ValtteriN_4-1666086417228.png

 

Selecting values from parameter slicer will change the legend






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

Proud to be a Super User!




Thank you so much for your great effort @ValtteriN  But let me clear my requirement again.

You can see my table and visual that is given below.
here I selected the 1 so my legends are short according to the alphabetic order same as 2 or 3 but instead of these three when 4 is selected from the slicer this my stocked bar chart legend must sort according to the value(sum of X_Axis) column.
DataDataVisualVisual

 
 
 

Hope it clears you 
Thank you
@ValtteriN 


@amitchandak



Hi @rashesh ,

 

I create a sample to have a test, I think Power BI doesn't support us to sort the bar chart by value in each legend. 

our demand is a good idea, while it is not supported to implement in Power BI currently.
You can vote up this idea for this function:Microsoft Idea (powerbi.com)
Or you can submit a new idea to improve the Power BI.
It is a place for customers provide feedback about Microsoft Office products . What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ValtteriN
Super User
Super User

Hi,

Here is one way to do this:

1. create measure:

Dynamic sort = var _val = MAX('Table 6'[Value]) return

SWITCH(TRUE(),
_val in {1,2,3}, MAX('Table (10)'[Column1]),
_val = 4, MAX('Table (10)'[Column2]))


Here table 6 = slicer values

Table (10) = column chart fact table

Data: 
ValtteriN_0-1666079034196.png

2. place the measure in a tooltip:

ValtteriN_1-1666079064275.png

3. Select sorting to happen based on this measure (... in the top right of the chart)

4. Based on selection the chart is sorted with numbers or with alphabet:
ValtteriN_2-1666079094736.png

 

ValtteriN_3-1666079105419.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/







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

Proud to be a Super User!




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors