web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Column chart sort asce...
Power Apps
Answered

Column chart sort ascending

(1) ShareShare
ReportReport
Posted on by 205
Hello experts,
 
My column chart has columns arranged in the order Green, Blue, Yellow, Red
How can sort ascending (order A to Z: Blue, Green, Red, Yellow)?
 
and I also want to sort in the same order for Legend of the column chart.
 
Thank you so much!
Regards,
ROSE
 
Categories:
I have the same question (0)
  • rubin_boer Profile Picture
    4,841 Super User 2024 Season 1 on at
    hi there @ROSEBLACK
     
    Your data needs a column that can be sorted the way you want it to be. 
     
    The following will assist you with the concept:
    • Your data (i will use a collection called __yourData) will have a name and a value, for example:
          {color: "Blue", total: 100},
          {color: "Green", total: 60},
          {color: "Red", total: 40},
          {color: "Yellow", total: 50}
    • Add a column that can be sorted, e.g. 
      SortByColumns(
          AddColumns(
              __yourData,
              sort_id, //add this column and the condition reflecting the sequence you desire
              Switch(
                  true,
                  color = "Blue",
                  1,
                  color = "Green",
                  2,
                  color = "Red",
                  3,
                  color = "Yellow",
                  4,
                  0
              )
          ),
          "sort_id",
          SortOrder.Ascending
      )
       
    Result
     
    Added Column and sorted, the same apply to the legend
     
    I hope it helps you on your journey!!.
     
  • ROSEBLACK Profile Picture
    205 on at
    Dear rubin_boer,
     
    Blue, Green, Red, Yellow are values in my choose column (name is ColorColumn) of MySharePoint list.
    Total may vary depending on input selection.
    Below are my codes.
     
    How can I add a SortOrder.Ascending for the code?
     
    AddColumns(
        AddColumns(
            GroupBy(
                AddColumns(
                    ShowColumns(
                        'MySharePoint',
                        ColorColumn
                    ),
                    ColorColumnNames,
                    ColorColumn.Value
                ),
                ColorColumnNames,
                Grp_Status
            ),
            NumberOfValues,
            Round(100*CountRows(ThisRecord.Grp_Status)/CountRows('MySharePoint'),2)
        ),
        LabelName,
        Concatenate(
            ColorColumnNames,
            " (",
            NumberOfValues,
            "%)"
        )
    )
  • Verified answer
    rubin_boer Profile Picture
    4,841 Super User 2024 Season 1 on at
     
    Please find the following:
     
    AddColumns(
        AddColumns(
            GroupBy(
                AddColumns(
                    ShowColumns(
                        'MySharePoint',
                        ColorColumn
                    ),
                    ColorColumnNames,
                    ColorColumn.Value
                ),
                ColorColumnNames,
                Grp_Status
            ),
            NumberOfValues,
            Round(100*CountRows(ThisRecord.Grp_Status)/CountRows('MySharePoint'),2)
        ),
        LabelName,
        Concatenate(
            ColorColumnNames,
            " (",
            NumberOfValues,
            "%)"
        ),
        'sort_id'.
      Switch(
                true,
                ColorColumnNames = "Blue", 1,
                ColorColumnNames = "Green", 2,
                ColorColumnNames = "Red", 3,
                ColorColumnNames = "Yellow", 4,
                0
      )
    )
     
    Consider the following code as well:
    With(
        {
            TotalRows: CountRows(MySharePoint)
        },
        AddColumns(
            GroupBy(
                AddColumns(MySharePoint, 'ColorColumnNames', ColorColumn.Value),
                'ColorColumnNames',
                'Grp_Status'
            ),
            'NumberOfValues_pct',
            Round(CountRows(Grp_Status) / TotalRows, 2) * 100,
            'ColumnNameWithPercentage',
            ColorColumnNames & " (" & Round(CountRows(Grp_Status) / TotalRows, 2) * 100 & "%)",
            'sort_id',
            Switch(
                true,
                ColorColumnNames = "Blue", 1,
                ColorColumnNames = "Green", 2,
                ColorColumnNames = "Red", 3,
                ColorColumnNames = "Yellow", 4,
                0
            )
        )
    )
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard