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 / Add Columns, Sort, and...
Power Apps
Unanswered

Add Columns, Sort, and Filter

(0) ShareShare
ReportReport
Posted on by 28

Hi friends. 

 

I can get each of these to work individually in the items setting of my gallery, however I am having trouble when trying to nest them. 

 

This works to SORT on the gallery but not filter:

 

 

 

SortByColumns(
 AddColumns(
 ReportDeliveryCustomerGroups,
 "MainCustomerName",
 'Main Customer Name'.Value
 ),
 "MainCustomerName",If(SortDescending2,Descending,Ascending)
)

 

 

 

 

This works to FILTER on the gallery but not sort: 

 

 

 

If(
 IsBlank(CustomerCombobox_2.Selected.Value),
 ReportDeliveryCustomerGroups,
 Filter(
 ReportDeliveryCustomerGroups,
 Customer.Value = CustomerCombobox_2.Selected.Value
 )
)

 

 

 

 

The closest I can come to not getting angry red lines everywhere is this: 

 

 

 

 

SortByColumns(
If(
 IsBlank(CustomerCombobox_2.Selected.Value),
 ReportDeliveryCustomerGroups,
 Filter(
 ReportDeliveryCustomerGroups,
 Customer.Value = CustomerCombobox_2.Selected.Value)
 ),
AddColumns(
 ReportDeliveryCustomerGroups,
 "MainCustomerName",
 'Main Customer Name'.Value
 )
"MainCustomerName"
)

 

 

 

but it's just not working. I've been putting commas and parentheses in different spots and I'm just going in circles. Please help me fix this silly thing. 

 

CDev_83_0-1677003439878.png

Thank you!!

C

 

Categories:
I have the same question (0)
  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @CDev_83 

    Rearranging a bit.

     

    With({_items:AddColumns(
     ReportDeliveryCustomerGroups,
     "MainCustomerName",
     'Main Customer Name'.Value
     )
     },
     SortByColumns(
     Filter(_items, IsBlank(CustomerCombobox_2.Selected.Value)||
     Customer.Value = CustomerCombobox_2.Selected.Value
     ),"MainCustomerName",Ascending
     )
    )
    

     

     

     

  • CDev_83 Profile Picture
    28 on at

    Thank you so much! I don't really ever use the "with" function, I appreciate the help

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @CDev_83 

    I like it because it makes the code so much easier to understand the logic, it doesn't slow down the processing of the code and unlike collections or variables, it only exists during the execution of the code.  I sometimes used to get lost in my own code when I went back to it months later.  I find this really helps. 

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard