Hello Friends,
Welcome back with another post of PowerApps. today, we will learn something new. Guess What? Have you ever faced any situation, where you have to create a collection of some sequential numbers - let's say from 1 to 10 or 24 to 35 or a date range? Do you know that we can achieve this in PowerApps. For this, PowerApps has provided a very powerful function named "Sequence". Let's see, how we can use this function-
- Getting Collection for 01-10 numeric values.
- The code is-
ClearCollect( SequenceCollection, Sequence(10) )
- The output is-
- Getting Collection for 24-33 numeric values-
- The code is-
ClearCollect( SequenceCollection, Sequence(10,24) )
- The output is-
- Getting Collection starting from 11 with an interval of 2-
- The code is-
ClearCollect( SequenceCollection, Sequence(10,1,2) )
- The output is-
- Getting Collection for next 10 days-
- The code is-
ClearCollect( SequenceCollection, ForAll( Sequence(10), DateAdd( Today(), Value, Days ) ) );
- The output is-
- The objective of this post is that most of the times, we need to apply loop in PowerApps for some N times. But as there is no loop function in PowerApps, we have to do some manipulation. We have ForAll function to achieve the loop functionality but it takes a collection as first parameter upon which it works. So, we have to create a collection on runtime using that we can achieve loop functionality.
- The use of Sequence with ForAll is explained in my below post-
- PowerApps: Getting More Than 2000 Items (Using Sequence)
- Visit the post and on point 10 & 11, I had used Sequence and ForAll respectively to fetch all items from data source.
- Visit below article by Microsoft on Sequence for further reading-
- Sequence function in Power Apps
With this, I am concluding this post.
Happy Coding !!!
Will see you again with some new topics.
Stay Safe !
Stay Healthy !
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.