cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mr-dang
Community Champion
Community Champion

Overcoming the 500 record limit locally

UPDATE 2/19/17: I had written a new solution for this method here. It works more efficiently for CDS.

____________________

 

A few days ago I shared the solution I have been using to pull in all records of an Entity into a temporary collection to overcome the 500 record limitation. You can read about it here.

 

Now that I've had some time to play with ForAll, I have a more elegant solution for pulling in 500 records at a time for reading. I still do not have a good solution for writing though. For this to work, you will still need a column in your Entity which describes which set of 500 it belongs to.

 

Big idea: 

  1. Find out what the maximum n value is that describes how many sets of 500 you have. The formula I included also repairs the datasource if the last entry did not correctly have an n recorded.
  2. Create a dummy collection that includes whole numbers that are less than or equal to the n value you found in step 1.
  3. Use the dummy collection in step 2 as an argument in ForAll--"For each n in the dummy table, collect the 500 records from the datasource which are equal to that n."

 

UpdateIf(datasource,IsBlank(n),
	{n: RoundDown(Value(PrimaryId)/500,0)+1
	}
);

UpdateContext({maxn: First(Sort(datasource,PrimaryId,Descending))});

ClearCollect(iter,
	Distinct(Filter(HundredChart,Num<=maxn.n),Num)
);

Clear(datasource_temp);

ForAll(iter,
	Collect(datasource_temp,
		Filter(datasource,n=Result)
	)
)

This can be done in a Button, Toggle, Timer, or whatever you want to trigger.

 

The only requirement is that you create a Table of whole numbers in a column [1,2,3,4,5, etc.] from which to pull your dummy collection. You can connect it to PowerApps as static data. I just used an existing "Hundred Chart" from a datasource I already connected. I do not know another way of making a collection with such whole number sets.

 

EDIT: Unfortunately, you will need to create an n value in your entity. I tried the following formula to try working around writng a column for n, but it has service limitations:

 

ForAll(iter,
	Collect(datasource_temp,
		Filter(datasource,(RoundDown(Value(PrimaryId)/500,0)+1)=Result)
	)
)

 

EDIT2:

Since UpdateIf does not delegate, you will not be able to fix all n that are blank. Instead, when writing a record, write n as 0 instead of blank so you can fix it. The change below can only fix the last record and may miss any others that do not have an n.

UpdateContext({maxn: First(Sort(datasource,PrimaryId,Descending))});

If(IsBlank(maxn.n) || maxn.n=0,
Patch(datasource,First(Filter(PrimaryId=maxn.PrimaryId)), {n: RoundDown(Value(maxn.PrimaryId)/500,0)+1 } )
UpdateContext({maxn: First(Sort(datasource,PrimaryId,Descending))})
); ClearCollect(iter, Distinct(Filter(HundredChart,Num<=maxn.n),Num) ); Clear(datasource_temp); ForAll(iter, Collect(datasource_temp, Filter(datasource,n=Result) ) )

 

 

@Meneghino@hpkeong@AmitLoh-Powerap: I think you would be interested in this.

Microsoft Employee
@8bitclassroom
19 REPLIES 19
hpkeong
Community Champion
Community Champion

Hi Brian @mr-dang

 

Thanks for much for the great effort in sharing delegation which is so crucial to most of us dealing with bulk data, esp. using those non-delegated formula.

 

I shall also check on the actual performance based on your sharing.

 

Once again, my appreciation.

 

Have a nice day, my friend.

hpkeong

Thank you for your help!

The savings on loading time are worth while:

 

Entity size: 4 entities with a total of 24 blocks of 500

 

Timer method: 1:03 - 1:10

ForAll method: 0:41 - 0:50

 

Tests were conducted on a stronger laptop, so YMMV. I expect Atom devices and Chromebooks should be much slower.

 

This represents a 42% reduction in loading time at best and 21% at worst. This is because ForAll can run concurrently. 

 

2017-01-16.png

 

 

 

 

Microsoft Employee
@8bitclassroom
mr-dang
Community Champion
Community Champion

I ran some new tests on a faster network:

 

Writing 24 sets of 500 records to temporary collections

 

Surface device (Chrome browser)

Timer method: 0:28 - 0:29

ForAll method: 0:17 - 0:18

 

Surface device (Edge browser)

Timer method: 0:30 - 0:37

ForAll method: 0:17 - 0:19 (Also 1:51 - 1:54)

 

Chromebook

Timer method: 0:31 - 0:36 

ForAll method: 0:16 - 0:17 (Also 1:31 - 1:39)

 

It put my Surface to shame when the Chromebook kept up to speed using the ForAll method. However, my tests were done in a mostly blank app. The Chromebook will definitely choke when Galleries and other calculations are based on your temporary collection that you are making. That's where the computer will need CPU and RAM to keep up. To avoid that, I put a condition on the Items property of Galleries so that when I am loading in data, the gallery does not need to recalculate its items for each 500 that is pulled in. It does need to recalculate at the end, but that's fine. I confirmed that I could still achieve around 0:32 - 0:36 on the Chromebook with this work around, but was unnecessarily minutes longer without the condition on Items properties (I quit).

 

In my testing there was a time when everything dramatically slowed on both devices. I listed the times in parentheses as well. You could tell that things were going to lag when the first n of 500 records went nowhere--normally I see it pull in within 3s. (this was around 3:30PM PST if that means anything). At first, I thought it was a Microsoft Edge issue, but retesting showed consistent results with Chrome on Windows. The Chromebook also returned to about 0:17 again. So the inconsistency in writing to CDS is either a problem with my network or on the backend of CDS.

 

Caveat: this testing was done under very ideal conditions. My students were gone for the day so I was likely the only one on the network. I also only tested one device at a time. In real scenarios, the load is unbearably slow for my students' Chromebooks--I do not get the 0:17. When all students are on, loading in the entities has gone as long as 3-5 minutes using the Timer method. It's hard to justify using the app with that amount of delay (students work on something else while it is loading). That's why I'm running these tests and trying to find faster methods.

 

Last comment: I made a critical error in my formulas. It turns out that UpdateIf cannot fix all n that are blank. In PowerApps, UpdateIf cannot update records outside of the first 500 if the argument is "IsBlank(n)"--it doesn't delegate. A blue error did not pop up, which caused me to believe that it did work. The obvious fix is to go into Excel to recalculate the n column in one shot. However, making a formula solve this problem is a better idea. I have a way of fixing the n for the last record, but not everything in between:

UpdateContext({maxn: First(Sort(datasource,PrimaryId,Descending))});

Patch(datasource,First(Filter(datasource,PrimaryId=maxn.PrimaryId)),
{n: RoundDown(Value(maxn.PrimaryId)/500,0)+1
}
)

Unfortunately, ForAll cannot delegate to fix all blank values of n either.

Microsoft Employee
@8bitclassroom

Hi Dang,

 

On button click how do you bring next 500, On timer I understand duration based it will do next. On button click how you bring set of 500(24 times)

 

One Button press is able to pull in everything because you identified the total number of sets of 500:

UpdateContext({maxn: First(Sort(datasource,PrimaryId,Descending))});

If(IsBlank(maxn.n) || maxn.n=0,
Patch(datasource,First(Filter(PrimaryId=maxn.PrimaryId)), {n: RoundDown(Value(maxn.PrimaryId)/500,0)+1 } )
UpdateContext({maxn: First(Sort(datasource,PrimaryId,Descending))})
);

 

The "iter" collection below identifies how many times you will pull in 500 by creating an ordered set of whole numbers [1,2,3,4,5,... maxn.n]:

 

ClearCollect(iter,
	Distinct(Filter(HundredChart,Num<=maxn.n),Num)
);

 

ForAll is able to repeat collecting 500 records for each record you have in the "iter" collection above. It means, "For All the whole numbers you collected in iter, collect the set of 500 records which have n equal to that whole number." So collect all 500 records with n=1, then all records with n=2... finally all records with n=maxn.n.

 

Since iterations are built into the function itself, you only need to click the button once.

Clear(datasource_temp);

ForAll(iter,
	Collect(datasource_temp,
		Filter(datasource,n=Result)
	)
)

 

Microsoft Employee
@8bitclassroom
hpkeong
Community Champion
Community Champion

Hi Dang:

 

I will explore this modified function after CNY.

You mentioned Two Buttons, which include:

- UpdateContext(...); If..(Patch)..., then

- ClearCollect....

- ForAll

...Are they different action or?

 

The frist argumenet UpdateContext({maxn:  ...}), and then If(IsBlank(maxn.n ||...

Are there referring to the same maxn or maxn.n?

 

Anyway, maybe by looking at it I can;t really figure out how but I will try then.

 

Glad to have new solutions exactly on the first day of Lunar New Year.

Thanks.

hpkeong
mr-dang
Community Champion
Community Champion

@hpkeong wrote:

You mentioned Two Buttons, which include:

- UpdateContext(...); If..(Patch)..., then

- ClearCollect....

- ForAll

...Are they different action or?

The three actions are all part of one Button.OnSelect. I just split them up in my post to explain each part of it.

@hpkeong wrote:

 

The frist argumenet UpdateContext({maxn:  ...}), and then If(IsBlank(maxn.n ||...

Are there referring to the same maxn or maxn.n?

 



 

The first UpdateContext({maxn: ...}) is to see what the n of the last record in the datasource is. Sometimes it can be blank or 0 if PowerApps closed on a user who was in the middle of Patching. So I fix the record with Patch, then find out what maxn is again. Ideally I could just UpdateIf on the datasource and fix all n, but it cannot delegate.

Microsoft Employee
@8bitclassroom
hpkeong
Community Champion
Community Champion

Thanks Brian

 

I will seriously look into this and see if there is any walkaround on this though rarely deal with big amount of data.

 

Have a nice day.

hpkeong

Helpful resources

Announcements

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!     Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!     Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!     UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!     European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!   Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!   For more events, click the image below to visit the Microsoft Community Days website.    

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip: Community User Groups

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!  

Top Solution Authors
Top Kudoed Authors
Users online (3,644)