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

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Distinct values in gal...
Power Apps
Unanswered

Distinct values in gallery

(1) ShareShare
ReportReport
Posted on by 102

Hi. I am very very new in PowerApps, so may duplicate questions asked earlier.

 

I have sharepoint list where two columns are fed to Gallery: Item Code and Description.

Ultimately Item Code and Description need to be unique pair, Item Code shall not have different Description in the list.

Since there are other column, Item Code and Description, list may have duplicates of this pair.

ITEM CODE                 Description                  Size

11111                          apple                            3

11111                          apple                            4

11112                          banana                         3

I am creating screen where new Item Codes can be added to the list, so need to gallery just shows what unique values of Item Code, or pair of Item Code and Description. So, if last Item code is 11112, 11113 can be assigned to orange.

 

I saw similar questions and solutions to them but was not able to understand the logic.

Please if you can help me, also instruct where to use solution: gallery item, selected row?

Thanks in advance.

Categories:
I have the same question (0)
  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at
    Re: Distinct values in gallery

    @Dulat 
    To achieve this, you can try to use the Distinct function in PowerApps, which should return a one-column table that consists of distinct values from the specified column of the source table.

     

    So, you can try and solve your issue as follows:

     

    1. First, navigate to the screen where your Gallery control is, in your Power Apps Canvas App.

    2. Now, in the Items property of the Gallery, instead of directly linking it to your SharePoint list, you can use the Distinct function. Assuming your SharePoint list is named MyList, you can use a formula like this:

     

    Distinct(MyList, {ItemCode: ItemCode, Description: Description})

     

    This should give you a gallery of unique ItemCode - Description pairs.

     

    To add new items to the SharePoint list, make sure to implement logic in your app to check whether the combination of ItemCode and Description is already present in the list before adding. This can be done using the LookUp function:

     

    If(IsBlank(LookUp(MyList, ItemCode = TextInput1.Text && Description = TextInput2.Text)),
    Patch(MyList, Defaults(MyList), {ItemCode: TextInput1.Text, Description: TextInput2.Text, Size: TextInput3.Text}),
    Notify("This Item Code and Description pair already exists!", NotificationType.Warning)
    )

     

    In the above formula:

    - TextInput1.Text, TextInput2.Text, and TextInput3.Text should be replaced by your actual text input control's names where you enter the new ItemCode, Description, and Size.
    - Patch is used to add a new item to the list.
    - LookUp checks if the ItemCode and Description pair already exists in the list.
    - IsBlank checks if the LookUp function returned anything.
    - If the pair does not exist, the new item gets added to the list.
    - If the pair does exist, a notification gets displayed.

    Remember to replace the names in the formulas in the above examples, with the actual names used in your app, such as your SharePoint list's name (your data source's actual name) and the actual names of your input text boxes in the Canvas App.

     

    Hope it helps @Dulat 

  • Dulat Profile Picture
    102 on at
    Re: Distinct values in gallery

    @poweractivate 

    Thanks for help!

     

    I have tried code with Distinct function, it worked. 

    But, I forgot to mention that my list is about 10K rows, with about 4K distinct values.

    It seems that Distinct function works with only less than 2K rows 😞

    Can you advise if there is way to cover 10K+ rows?

    Or using Sharepoint List as a source is bad idea in this case?

     

    Also, could you please advise how to sort values from the Distinct function?

     

    Thanks!

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at
    Re: Distinct values in gallery

    @Dulat 

     

    2k is the "record limit " or "row limit". The default is actually 500, and you can raise it to a max of 2,000.
    No single function call may return more than the record row limit, EVEN if it is delegable. 
    How this works is your most innermost Filter should return less than 2k records. The innermost filter should probably be ideally delegable as well (if it's not delegable, not all the records will be processed, only the 1st 2k will be processed). EVEN when delegable, a max of 2k is returned by a function call, which is a distinct concept from the delegation concept.

     

    This whole thing is an advanced concept and depends on your scenario.

    The answer is YES with 10k or even 100k you can do your scenario.
    You need to keep thinking and get a single function to return less than 2000 records especially in the innermost function.


    One thing where Dataverse may shine is you can delegate the in if you have to use "in" (there's still tricks without needing this).

    Note that even with delegable, you can never escape the 2k, this is something you can't escape from regardless what you use as client has reasonable limits in general. See if you can figure out how to arrange it so your single function returns less than 2k. For example in your distinct 4k,  is there a filter that can bring that down right away to < 2k? This would be a Filter that may have an && to filter on more than one column for example.

     

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 231 Super User 2025 Season 2

Last 30 days Overall leaderboard