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 / Filtering Sub-Gallery ...
Power Apps
Unanswered

Filtering Sub-Gallery by DISTINCT values

(0) ShareShare
ReportReport
Posted on by

Hi all, 

 

I'm so stuck on this I hope someone can nudge me in the right direction. 

 

I have a gallery & a sub-gallery: 

DouglasStamper_0-1649760588181.png

 

When the user selects the value of the top gallery, in this case ""Alloa WWTW influent flow", the sub-gallery drops down & the user should be able to select the particular Signal ID row which subsequently opens the form component on the right hand side so they can make changes. 

 

DouglasStamper_1-1649761686585.png

 

However, I have loads of duplicates showing, where as I really need just one unique record, based on Signal ID to show. 

 

DouglasStamper_2-1649761800649.png

 

My current formula for the top gallery is: 

 

Search(
 Sort(
 RenameColumns(
 Distinct(
 'FLOWRETURNS.MANUAL_UPDATE',
 SW_Unique_Measurement_Point
 ),
 "Result",
 "SW_Unique_Measurement_Point"
 ),
 SW_Unique_Measurement_Point
 ),
 txtSearch_1.Text,
 "SW_Unique_Measurement_Point"
)

 

This works fine - no issues with this. 

 

My sub-gallery's Item property is set to: 

 

Filter('FLOWRETURNS.MANUAL_UPDATE', SW_Unique_Measurement_Point = ThisItem.SW_Unique_Measurement_Point)

 

I know this won't achieve my needs but I have tried multiple formula's, including: 

 

Distinct(Filter('FLOWRETURNS.MANUAL_UPDATE',SW_Unique_Measurement_Point=ThisItem.SW_Unique_Measurement_Point),Signal_ID)

 

And: 

 

ForAll(Distinct('FLOWRETURNS.MANUAL_UPDATE',SW_Unique_Measurement_Point),LookUp('FLOWRETURNS.MANUAL_UPDATE',Signal_ID=ThisRecord.Signal_ID))

 

However, nothing has worked. Maybe my understanding of filtering/distinct on a sub-gallery isn't perfect but I am at a loss on how to achieve this. 

 

Can anyone provide any clues?

 

I am using SQL as my data source. 

 

Many thanks, 

 

Doug

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    Hi @DouglasStamper ,

    The issue you have is that a Distinct filter only returns one column (Result) and therefore Signal_ID will not be in the data - tTry this on the Items of the Parent gallery

    Search(
     Sort(
     GroupBy(
     'FLOWRETURNS.MANUAL_UPDATE',
     "SW_Unique_Measurement_Point",
     "Data"
     ),
     SW_Unique_Measurement_Point
     ), 
     txtSearch_1.Text,
     "SW_Unique_Measurement_Point"
    )

    and then the Items of the nested gallery

    Distinct(
     ThisItem.Data,
     Signal_ID
    ).Result

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • DouglasStamper Profile Picture
    on at

    Hi @WarrenBelz

     

    Many thanks for the reply!

     

    I implemented your solution, however I'm not getting any data now at all: 

     

    DouglasStamper_0-1649764608653.png

     

    Just to confirm. - Parent Gallery Item property is: 

     

    earch(
     Sort(
     GroupBy(
     'FLOWRETURNS.MANUAL_UPDATE',
     "SW_Unique_Measurement_Point",
     "Data"
     ),
     SW_Unique_Measurement_Point
     ), 
     txtSearch_1.Text,
     "SW_Unique_Measurement_Point"
    )

     

    And child gallery is: 

     

    Distinct(
     ThisItem.Data,
     Signal_ID
    ).Result

     

    I also see a 'semi' error message saying the formula uses scope that which isn't supported for evaluation. 

     

    Many thanks!

     

    Doug

  • WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    @DouglasStamper ,

    Firstly, the parent gallery code is valid providing your field values are (I just tested it here to check). In nested one unfortunately you seem to want to see a lot of other fields - both GroupBy and Distinct will only return one field - it you want others you need to do something like this

    AddColumns(
     GroupBy(
     ThisItem.Data,
     "Signal_ID",
     "Data2"
     ),
     "Field1",
     First(Data2).Field1Name,
     "Field2",
     First(Data2).Field2Name',
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • DouglasStamper Profile Picture
    on at

    Hi @WarrenBelz ,

     

    Again, thank you - I feel like I am getting closer!

     

    One quick question - what do you mean by "Data2" in your solution? Apologies for my poor understanding. 

     

    I've currently built it up like this:

     

    AddColumns(
     GroupBy(
     ThisItem.Data,
     "Signal_ID",
     "SW_Unique_Measurement_Point" 
     ),
     "Signal Name",
     First('FLOWRETURNS.MANUAL_UPDATE').Signal_Name,
     "Signal ID",
     First('FLOWRETURNS.MANUAL_UPDATE').Signal_ID,
     "SW Point Description",
     First('FLOWRETURNS.MANUAL_UPDATE').SW_Unique_Measurement_Point,
     "Process Scientist",
     First('FLOWRETURNS.MANUAL_UPDATE').Process_Scientist
    )

     

    I know its not correct, placing one of my fields in place of "Data2" but I can see now how it is supposed to be structure, just a little unclear on the "Data2". 

     

    If it makes any difference, my data source is a SQL view, does that make any difference?

     

    Thanks, 

     

    Doug

  • Verified answer
    WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    @DouglasStamper ,

    When GroupBy is used, the last reference needs to be the table field that all the fields matching the grouped column/s are stored. I probably could have used "Data", but has already done so in the Parent GroupBy, so used something different to avoid possible ambiguity. You can actuully call it whatever you want (HomerSimpson would work . . .)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • DouglasStamper Profile Picture
    on at

    Thank you @WarrenBelz - Life Saver!

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard