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 : U+d+QFss5fPeoVIACly51U
Power Apps - Building Power Apps
Answered

OnVisible ClearCollect or Collect is not returning all records from datasource

Like (0) ShareShare
ReportReport
Posted on 30 Oct 2021 07:28:30 by 34

Ok, I'm really stumped. I have a ClearCollect function firing in the OnVisible of the page to collect records from a sharepoint list and it is missing a chunk of records. I'm supposed to get 272 records but only returns 96.

 

So I copied the code exactly as is into the OnSelect of a button and pressed it.  It returned all 272 records.  The code is identical.  I don't understand why the button would return the correct # of records but not the one that's in the OnVisible event.  Any ideas?

 

Clear(tempNetForDisplay);
Collect(
 tempNetForDisplay,
 ShowColumns(
 Filter(
 VarSupplyList,
 SA = varSA && FA = varFA && VER = VarDDCurr && SupplyType = VarSupplyType
 ),
 "SA",
 "MCA",
 "FA",
 "SupplyType",
 "VER",
 "Service",
 "Year",
 "Data",
 "ID"
 )
);
Collect(
 tempNetForDisplay,
 ShowColumns(
 Filter(
 VarSupplyList,
 SA = varSA && FA = varFA && VER = VarDDPrior && SupplyType = VarSupplyType
 ),
 "SA",
 "MCA",
 "FA",
 "SupplyType",
 "VER",
 "Service",
 "Year",
 "Data",
 "ID"
 )
)
  • Thrive Profile Picture
    34 on 04 Nov 2021 at 16:10:33
    Re: OnVisible ClearCollect or Collect is not returning all records from datasource

    Hi @WarrenBelz ,

    Thanks for checking.  I decided to do away with setting the datasource table name as a variable and hardcode it.  Since I have a lot of tables, I had to write a long switch statement.  It wasn't my 1st choice but it works fine now.  The downside to this is repetitive code since only the table name is really changing.  Thanks for your suggestion about setting the table as a global variable or creating a collection.  Unless I misinterpreted, it would mean I'd have to store the entire table and didn't want to do that because the tables are huge.

  • WarrenBelz Profile Picture
    149,183 Most Valuable Professional on 04 Nov 2021 at 08:38:51
    Re: OnVisible ClearCollect or Collect is not returning all records from datasource

    Hi @Thrive ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    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

  • Verified answer
    WarrenBelz Profile Picture
    149,183 Most Valuable Professional on 30 Oct 2021 at 08:24:42
    Re: OnVisible ClearCollect or Collect is not returning all records from datasource

    Hi @Thrive ,

    If you are going to store a Table, make a Collection, not set a Variable (you can store Values and Records in those). I am actually surprised the code works at all.

    If you have colSupplyList (you did not say how you set that Variable), your code should work fine if those are Global Variables you are filtering on, however your last comment is a bit confusing, you are starting with a Table and then setting the same item to a single Value - these will be incompatible types anyway.

     

    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.

  • Thrive Profile Picture
    34 on 30 Oct 2021 at 08:15:08
    Re: OnVisible ClearCollect or Collect is not returning all records from datasource

    Hi @WarrenBelz ,

     

    VarSupplyList  is a context variable.  I want to dynamically switch datasources based on a toggle.

    If the toggle control it on (true), the datasource is the test table, otherwise it is regular table.

     

    varSA and varFA are global variables and they show as correct values.

     

    Does Collect or ClearCollect not work with variables for datasources??? So I created another test button to troubleshoot the code further.  Instead of switching the context variable conditionally for dynamic datasource, I set the context variable to just the test table.  Still pulling the wrong # of records.  Then, I hardcoded the table in the collect function and only then does it work.

     

    UpdateContext({VarSupplyType: "NET_NEW"});
    
    If(toggle1.value = true,
     UpdateContext({VarSupplyList: 'Supply Test'}),
     UpdateContext({VarSupplyList: 'Supply'})
    )

     

     

  • WarrenBelz Profile Picture
    149,183 Most Valuable Professional on 30 Oct 2021 at 07:42:00
    Re: OnVisible ClearCollect or Collect is not returning all records from datasource

    Hi @Thrive ,

    Two things I spotted here

    • Is VarSupplyList a Variable or a Collection?
    • Where do you set the Variables varSA, varFA, VarDDPrior & VarSupplyType​ and are they global or context Variables (Set or UpdateContext)
    • You seem to have the same code twice

     

  • Thrive Profile Picture
    34 on 30 Oct 2021 at 07:32:58
    Re: OnVisible ClearCollect or Collect is not returning all records from datasource

    @WarrenBelz , edited post to include code

  • WarrenBelz Profile Picture
    149,183 Most Valuable Professional on 30 Oct 2021 at 07:30:06
    Re: OnVisible ClearCollect or Collect is not returning all records from datasource

    Hi @Thrive ,

    You might supply some code here (in Text) of your ClearCollect.

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

Telen Wang – Community Spotlight

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

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