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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Distinct, Sort in Casc...
Power Apps
Answered

Distinct, Sort in Cascading Dropdowns and Gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I need help with a Gallery and a Table. Both are pulling different data from the same SP list using a series of three cascading dropdown fields each. 

 

Dropdown1 = Region; Dropdown2 = City; Dropdown3 = Street; The Dropdowns are pulling data from a from a SP list called LocationLst.

 

Dropdown1 Item is - Sort(Distinct(LocationLst,State),Result). This returns all State name once, as desired.

 

Dropdown2 Item is - Filter(LocationLst, State=Dropdown1.Selected.Result). This returns all examples of each city on the list, and not in order. I'd like this filter to return all Cities once, in Ascending (A-Z) order.

 

Dropdown3 Item is - Filter(LocationLst, City=Dropdown2.Selected.Park). This returns all Street names on list, and not in order. I'd like this filter to return all Street names once, in Ascending (A-Z) order.

 

Gallery1  is pulling data from a separate SP list called EverywhereLst. The Gallery1 Item is set at - EverywhereLst, and returns all 1700 line items in the three columns set up in the Gallery, rather than just the data specific to the Street selected in Dropdown3.

 

Any suggestions for how to set up the three cascading dropdowns to pull only unique ascending State, City, Street data in each field, in ascending order, and have the Gallery pull corresponding data from a separate list based on the Street name selected in Dropdown3?

 

A lot, I know. Thanks!

 

 

Categories:
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It looks like you're almost there. For returning your dropdowns in ascending order you should be able to use Sort like you did for the first dropdown. Just use the column you want to be sorted as the argument.

     

    EDIT: If you want to use distinct, you can do it the same as you did for the first dropdown. To avoid using Result as the column name you can add RenameColumns to the front of your table argument.

     

    For the gallery,

     

     

    Filter(sourcetable, street = Dropdown3.Seleccted.street)

     

     

     

    I believe that should get you there.

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Anonymous 

    The formulas and results are in the screenshot.  I could have added addresses but didn't for privacy.  Annotation 2020-04-22 094916.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Made the change. I got the Yield sign, letting me know that there is a delegation issue. However, it did the work and returned the same. No change. All park in region, out of order and repeats rather than one only.

     

    Sort(LocationLst, State=Dropdown2.Selected.Result)   The system wouldn't give me 'Value' as an option for this formula, as you recommended.

     

    DD1 (no change to my original filter) - works, and brings back single instance of each State; DD2 (with your change, no change to outcome - still returns duplicates of City and out of order; DD3 (no change to my original filter) - works, and brings back single instance of each street based on selection in DD2.

     

    Gallery (based on data from different list), should bring back only details of Street chosen in DD4.

     

    Thanks,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Let's see if we can do this in pieces.

    So your first table has columns Region, City, Street.

    For Dropdown1 Items : 

     

     

     

    Sort(RenameColumns(Distinct(Table, Regions),"Result", "Regions"),Regions).Regions

     

     

     

     I'll add with edits.

     

    Dropdown2 Items:

     

     

     

    Sort(RenameColumns(Distinct(Filter(Table, Region = Dropdown1.Select.Regions), City), "Result", "Cities"), Cities).Cities

     

     

     

    Dropdown3 Items:

     

     

     

    Sort(RenameColumns(Distinct(Filter(Table, Region = Dropdown1.Selected.Regions, City = Dropdown2.Selected.Cities), Street), "Result", "Streets"), Streets).Streets

     

     

     

    Now I need to clarify, you want the gallery to show all records from a different table that have one of the streets listed in dropdown3? Or no, you want to pull in all records with the specific street chosen in Dropdown3.

     

    So for that just use the additional table as the gallery source and filter it based on the Dropdown3.Selected.Streets.

     

     

     

    Filter(sourcetable, StreetCol = Dropdown3.Selected.Streets)

     

     

     

    The delegation warning is because of Distinct. You can get around this by making collections as you go. How many records are you working with?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    With a little tweak to what you provided I got the result I desired. Thank you sooo very much.

     

    If you come up with a way to populate the Gallery based on the User().FullName from Off365 user let me know. That way I can get rid of all those dropdowns. 🙂

     

    I'm already collecting the UserName with Set(varUser, User()) at the App OnStart, and I have a text field on the canvas collecting the Off365 UserName, as a visual for the end user. Anyway to trigger a filter using the UserNm on this same Gallery on open?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    As long as there is a column in the table that would match up then yes. Are the user names recorded on the tablel in the same format as they are in the User() list? If not you'll have to do some concatentation juju to make it match up. OR actually, you might be able to use the search function since it automatically uses wildcards. What's the name format in the gallery source table? Like is it Last, First, MI or something like that? 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Way ahead of ya on that one. Created a column in SP list column that holds an exact version of the office database user name. Created an line item with my name on it on the list. Created a Text field on the canvas for the office database user name results. That populates my name 'John Doe' just fine. How would I 'OnStart' make the Table or Gallery (things don't seem to always work the same in both even though the task is the same), auto-populate data specific only to the content of the UserNm text box?

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I'm back again; with a new set of dropdowns and a new Gallery. I used the following...

     

    DD1 Item: Sort(Distinct(ListName,ColNm),Result) - Work fine. Returns list of Regions, with no duplicates.

    DD2 Itme: Distinct(Filter(ListName,CoNlm = DD1.Selected.Result),Park) - Work fine. Returns list of Parks, with no duplicates.

    DD3 Item: Distinct(Filter(ListName, ColNm = DD2.Selected.Result),LocDscrpt) - Works fine. Returns list of Locs, with no duplicates.

    Gallery Item: Distinct(Filter(ListName, ColNm = DD3.Selected.Result),LocDscrpt - Not working. I get red error circles saying

                                  The Gallery is retrieving data from a separate list than the DDs, with the unique value being he LocDscpt field in both.

                                  If I leave the Gallery Item as the default 'ListName' the first item in the list, based on the chosen Location in DD3

                                 appears and repeats. No other shows.

                                 If I change the Gallery filter to the filter above, the Gallery card appears fine (meaning no error), however all the Gallery

                                 text box fields show the following error "Name isn't valid. The following identifier isn't recognized".

    Thoughts?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    In your filters you've put "ListName" as source. I assume that's just a placeholder for this public form and the actual source name is different. Can you clarify, are you using the same table name "ListName" in both your dd filters and your gallery filter? If so, that won't work the way you want I don't think.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    First, you're a god-send! Thank all of you on these forums for your dedication to your skill and craft!

     

    Second, I solved my problem. It was in the data...operator error, as they say. 🤣

     

    Thanks,

     

    Now, can we get back to that query by system user name issue? I can't seem to get it to work. I've got User Name stuff everywhere; on the App on 'On Start' the Set and User are locked in so that is knows who's logged in. That user name is displayed in  a text box on each Screen of the App. I have tables and gallery being filter by cascading dropdowns that could just as easily (I assume) be filtered on open by the User Name, yes?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard