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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
guy17829393
New Member

Sort X-axis Line and clustered column chart

Hey,

I want to sort a X-axis from a line and clustered column Chart (variable sortedChart) and show only another column call (values) is it possible??

 

1 ACCEPTED SOLUTION
v-jtian-msft
Community Support
Community Support

Hi,@guy17829393.Hello, @parry2kThank you very much for your help on this issue, now I  want to share my solution below .
I am glad to help you.

According to your description, you are trying to implement a sorting function for the x-axis of a line/bar chart, right.

In response to your later question "show only another column call (values) is it possible?", could you elaborate a bit more on what you mean?

Could you elaborate a bit more on what you mean, if you can provide me with non-sensitive data, it would be very helpful in solving your problem.

Here are the results of my test, I hope it can help you.

Normally, if the data in the X-axis is simple data, such as data type, date type, then Power BI Desktop can sort it by default. However, you can customize the index columns and sort the X-axis based on the custom columns

vjtianmsft_0-1715670047681.png

My test data is as follows.

vjtianmsft_1-1715670128262.png

1. Create a new custom sorting column: C_sortIndex

C_sortIndex = 
 SWITCH(TRUE(),
 test_data[x_Name]="A",1,
 test_data[x_Name]="B",2,
 test_data[x_Name]="C",3,
 test_data[x_Name]="E",4,
 test_data[x_Name]="D",5
 )

2. Relying on the X-axis stored columns to re-create a calculated column, so that the value of the same, so as to avoid direct use of the X-axis based on the creation of the column C_sortIndex sorting circular dependency problems:

vjtianmsft_2-1715670178814.png

PS: Sorting directly on the original columns of the X-axis will cause a circular dependency problem.
Here's the right way to do it.

vjtianmsft_3-1715670207987.png

x_sortValue = 'test_data'[x_Name]

3. Sort the newly created column “x_sort” using the created index column ordering.

vjtianmsft_4-1715670314464.png

4. Re-create visual, the realization of the bar chart in the X-axis by customizing the order of the columns to be sorted.

vjtianmsft_5-1715670344752.png

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

Best Regards,

Carson Jian,

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









View solution in original post

2 REPLIES 2
v-jtian-msft
Community Support
Community Support

Hi,@guy17829393.Hello, @parry2kThank you very much for your help on this issue, now I  want to share my solution below .
I am glad to help you.

According to your description, you are trying to implement a sorting function for the x-axis of a line/bar chart, right.

In response to your later question "show only another column call (values) is it possible?", could you elaborate a bit more on what you mean?

Could you elaborate a bit more on what you mean, if you can provide me with non-sensitive data, it would be very helpful in solving your problem.

Here are the results of my test, I hope it can help you.

Normally, if the data in the X-axis is simple data, such as data type, date type, then Power BI Desktop can sort it by default. However, you can customize the index columns and sort the X-axis based on the custom columns

vjtianmsft_0-1715670047681.png

My test data is as follows.

vjtianmsft_1-1715670128262.png

1. Create a new custom sorting column: C_sortIndex

C_sortIndex = 
 SWITCH(TRUE(),
 test_data[x_Name]="A",1,
 test_data[x_Name]="B",2,
 test_data[x_Name]="C",3,
 test_data[x_Name]="E",4,
 test_data[x_Name]="D",5
 )

2. Relying on the X-axis stored columns to re-create a calculated column, so that the value of the same, so as to avoid direct use of the X-axis based on the creation of the column C_sortIndex sorting circular dependency problems:

vjtianmsft_2-1715670178814.png

PS: Sorting directly on the original columns of the X-axis will cause a circular dependency problem.
Here's the right way to do it.

vjtianmsft_3-1715670207987.png

x_sortValue = 'test_data'[x_Name]

3. Sort the newly created column “x_sort” using the created index column ordering.

vjtianmsft_4-1715670314464.png

4. Re-create visual, the realization of the bar chart in the X-axis by customizing the order of the columns to be sorted.

vjtianmsft_5-1715670344752.png

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

Best Regards,

Carson Jian,

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









parry2k
Super User
Super User

@guy17829393 sorry your question is not fully clear, could you please provide more details?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.