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 : wtvkwt6x4uRbvfYyUGfiwi
Power Apps - Building Power Apps
Unanswered

Is there absolutely no way of getting distinct values from a large sharepoint list?

Like (0) ShareShare
ReportReport
Posted on 1 Feb 2020 13:56:19 by 486

Is there any way of getting distinct values from a large(2000+ items) sharepoint list column? 

I'm getting rather frustrated with always butting my head against sharepoint and Odata. I was just now attempting to use a timer to gather everything from a list in 2000 item batches and using distinct() in the app to process the data. Its a dirty hack, and I only mention it to illustrate how desperate I have become. And now I just realised that the problem with this latest desperate attempt, is that that the operators >, <  doesn't work with the ID column! oh my, why!?😩

 

SharePoint has been a pain to deal with since day one when I started working on PowerApps solutions to replace Excel in various tasks. Now it looks like my endeavour is heading for a complete failure, as I always end up spending too much time on working around the limitations of sharepoint as a backend. 

 

I think that Odata V4 will provide some more delegatable functions like groupby etc ($Apply) . anyone know if SharePoint will ever support Odata v4?

 

PS: I am not be able to make use of CDS or a SQL backend, the environment I work in will not allow for that. This has to be solved using sharepoint lists. 

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    on 05 Feb 2020 at 12:38:10
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    Hello @Pstork1   can you please at my issue too.

     

    https://powerusers.microsoft.com/t5/General-Power-Automate/Send-email-with-multiple-attachments-from-SP-list/m-p/461697#M45447 

     

    Thanks in advance,

    Sanket

  • hjaf Profile Picture
    486 on 04 Feb 2020 at 07:15:55
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    I think I got power automate "delegation" working. There was no obvious reason for it not working before, but I fixed it by putting each result into respective variables before applying a union() expression. this seems to be working well now and is able to retrieve distinct values from about 8000 items in just a few seconds. 

    image.png

    In powerapps this flow-response object can be collected with:

    ClearCollect(SomeCollection, 'PowerAutomateFlowName'.Run())

     

    This requires the use of response which is a premium feature, so if this is to be considered a solution its only for those who have a premium.

  • hjaf Profile Picture
    486 on 04 Feb 2020 at 06:55:04
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    The calculated column datatype, even when selecting its type as number, is not a number for powerapps, also the column cannot be indexed.

    hover tooltip errorhover tooltip error

     

     

     

     

     

    Creating a numeric column with ID as calculated default gives me a error: 

    "Sorry, something went wrong
    The formula contains reference(s) to field(s)."
  • WarrenBelz Profile Picture
    149,223 Most Valuable Professional on 03 Feb 2020 at 21:46:50
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    @Pstork1 's solution will work - just have a numeric field in SharePoint with the default of the ID.

  • Pstork1 Profile Picture
    67,356 Most Valuable Professional on 03 Feb 2020 at 20:47:27
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    If you are going to create a calculated column you can just do one that copies the ID.  > or < don't work with the ID column itself, but it will work with an integer column, so you might try that.

  • hjaf Profile Picture
    486 on 03 Feb 2020 at 18:35:40
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    I see @Pstork1 , however, this assumes that there are less than 2000 items that starts with each letter, in my case there are perhaps just 10 different letters at the start of the columns. Perhaps I could make a calculated column that generates a letter based on the ID value or something 🤔, but i guess since its not possible to use <> operators on ID in by powerapps, I guess calculation has the same limitation. And I guess its not possible to do filtering on calculated columns anyway.

     

    In any case, its probably better than just starting from each end as I have currently done. 

    I have recently been exploring something I was able to do with large excel tables, but deploying the same method on SharePoint lists seems unstable for some reason. Sometimes it works and sometimes it just times out. The neat thing (if this worked) is that its fairly fast compared and less dependent on a good connection as the filtering and distinction logic is delegated to PowerAutomate / Flow 

    image.png

    Each of the two get items get 4000 items from each direction with either one with orderBy ID asc or ID desc.

    But sadly this does not seem stable as it times out at the response action. Everything is concerning sharepoint and union() finished in a few seconds similar to the screenshot posted, but then just idle at the response until it fails with a 504 Gateway Timeout. I have not figured out why yet. 

     

    The excel method I mentioned is described in this post. Its also note mentioning that I was able to get a large (6000+ items) collection into powerapps using this method, but it was obviously struggling when i tried loading the whole collection into a gallery or table 😄

     

     

     

  • mdevaney Profile Picture
    29,987 Moderator on 01 Feb 2020 at 21:59:20
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?
    @WarrenBelz
    I’m glad to hear you do this too. I figured this out for myself awhile ago but I was starting to wondering if many others were doing it.
  • WarrenBelz Profile Picture
    149,223 Most Valuable Professional on 01 Feb 2020 at 21:21:57
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    Hi @hjaf ,

    @Pstork1 has pretty much covered this.

    I will as well endorse @mdevaney‘s method if it suits you as I have in the same frustration made a practice of having seperate lists for any common values under about 100 items. His idea on  auto collecting is a good one - I had staff maintaining these.

  • Pstork1 Profile Picture
    67,356 Most Valuable Professional on 01 Feb 2020 at 21:10:14
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    In my case the distinct entries were based on names.  So I did a collection where I pulled all the distinct Fullnames that started with "A", then "B", etc. Since I pulled all the A's and B's etc in one batch it was guaranteed that I only pulled the distinct since there would be no overlap between something that started with A and something that started with B.  But it all depends on what you've to to work with as distinct fields.

  • mdevaney Profile Picture
    29,987 Moderator on 01 Feb 2020 at 15:09:42
    Re: Is there absolutely no way of getting distinct values from a large sharepoint list?

    @hjaf
    My idea would be to store the unique values in a a new SharePoint list. I will provide some inspiration below. I’ve used a similar technique in SharePoint before but I had a different goal than you.

     

     

    Example: Get A Unique List of Customers From A SharePoint List Of Customer Invoices


    For example let’s say you have a SharePoint list for Customer Invoices. A customer may have one or more invoices. However, you want to obtain a list of unique Customers.

    To do this we create a new SharePoint list called Customers.

    Next we make a PowerApps form used to data enter new invoices into the Customer Invoices list. We put this code in the OnSuccess property of the form to check if the customer exists in the Customers list. If the customer does not already exist we PATCH them to the Customers list.

    Set(myRecord, LookUp(Customers, CustomerName=Form1.LastSubmit.CustomerName));
    If(IsBlank(myRecord),Patch(Customers, Defaults(Customers), {CustomerName=myRecord.CustomerName});


    Now that we have a list of unique customers in SharePoint we can easily reference the unique names with this code.

    Customers.CustomerName

     

     


    Hopefully this brief example makes sense.

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

     

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete