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

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

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

@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

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

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,100)