Wednesday, June 30, 2021

PowerApps: Sequence Function

 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-

  1. Getting Collection for 01-10 numeric values.
  2. The code is-
  3. ClearCollect(
        SequenceCollection,
        Sequence(10)
    )
    
  4. The output is-


  5. Getting Collection for 24-33 numeric values-
  6. The code is-
  7. ClearCollect(
        SequenceCollection,
        Sequence(10,24)
    )
    
  8. The output is-


  9. Getting Collection starting from 11 with an interval of 2-
  10. The code is-
  11. ClearCollect(
        SequenceCollection,
        Sequence(10,1,2)
    )
    
  12. The output is-


  13. Getting Collection for next 10 days-
  14. The code is-
  15. ClearCollect(
        SequenceCollection,
        ForAll(
            Sequence(10),
            DateAdd(
                Today(),
                Value,
                Days
            )
        )
    );
    
  16. The output is-


  17. 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.
  18. The use of Sequence with ForAll is explained in my below post-
  19. PowerApps: Getting More Than 2000 Items (Using Sequence)
  20. Visit the post and on point 10 & 11, I had used Sequence and ForAll respectively to fetch all items from data source.
  21. Visit below article by Microsoft on Sequence for further reading-
  22. 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.