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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Initialising array dyn...
Power Automate
Suggested Answer

Initialising array dynamically - Part 2

(0) ShareShare
ReportReport
Posted on by 169
 
I'm using this Flow to extract data from a Sharepoint list with more than 5000 rows.  I get the lowest and highest ID.  Then I initialise the threads variable, so I can query Sharepoint the right number of times.  At the moment I'm hardcoding 4 elements into the array and the Flow runs the Apply to each 4 times. 
This means the Flow will retrieve data from a list containing up to 20000 rows.
 
Instead of hardcoding 4 elements into the array and concurrency control, is it possible to work out the highest ID - lowest ID and divide the difference by 5000.
For example if my Sharepoint list has 27000 rows, I would want 6 elements in the array.
 
I was given the formula below.  It works if there are many records.
How can I get it to also work if there is only one record ie first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Highest_ID')['body']['value'])['ID'] = first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Lowest_ID')['body']['value'])['ID']?  It's returning an empty array.
 
range(
	1,
	if(
		greater(
			indexOf(
				string(
					div(
						sub(
							float(
								first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Highest_ID')['body']['value'])['ID']
							),
							float(
								first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Lowest_ID')['body']['value'])['ID']
							)
						),
						5000
					)
				),
				'.'
			),
			0
		),
		add(
			int(
				formatnumber(
					div(
						sub(
							float(
								first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Highest_ID')['body']['value'])['ID']
							),
							float(
								first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Lowest_ID')['body']['value'])['ID']
							)
						),
						5000
					),
					'#0'
				)
			)
			,1
		),
		int(
			formatnumber(
				div(
					sub(
						float(
							first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Highest_ID')['body']['value'])['ID']
						),
						float(
							first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Lowest_ID')['body']['value'])['ID']
						)
					),
					5000
				),
				'#0'
			)
		)
	)
)
 
Categories:
I have the same question (0)
  • Suggested answer
    AH-02011058-0 Profile Picture
    169 on at
    I came up with this, but don't want to mark it as an answer in case one of you finds a bug in it.
     
    @{range(0,if(greater(indexOf(string(div(sub(float(first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Highest_ID')['body']['value'])['ID']),float(first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Lowest_ID')['body']['value'])['ID'])),
    5000)),'.'),0),add(int(formatnumber(div(sub(float(first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Highest_ID')['body']['value'])['ID']),float(first(outputs('Send_an_HTTP_request_to_SharePoint_Get_Lowest_ID')['body']['value'])['ID'])),
    5000),'#0')),1),int(formatnumber(1,'#0'))))}
  • CU30121719-0 Profile Picture
    on at
    Modify the request to return count.
  • Chriddle Profile Picture
    8,708 Super User 2026 Season 1 on at
    The expression seems to be wrong from the start (and unnecessarily complicated 😉).
    You can simply use Integer division and always add 1.
     
    range(
    	0,
    	add(
    		div(
    			sub(
    				outputs('Compose').maxId,
    				outputs('Compose').minId
    			),
    			5000
    		),
    		1
    	)
    )
    minId
    maxId range
    1 5000 [0]
    1 1 [0]
    1 5001 [0, 1]
    1 27000 [0, 1, 2, 3, 4, 5]
     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard