dynamicpowerappspowerapps-canvaspowerapps-formula

Dynamic input required in Powerapps


I want to dynamically input some data into powerapps. I have a variable x which is set to different numbers each time app is opened. When x is 1 I want one text input and when x is 10 I want 10 text inputs to come onto the screen. How can I achieve that?

I am currently using the Vertical Gallery and trying to set its Items property to x, the variable. But, it shows an error.


Solution

  • You can use the Sequence function to create a table with the size of the variable you have, and then use that table as the Items property of a gallery. For example, in the screen capture below the gallery Items property is set to Sequence(x), and as I update the value in the left text input (and hit to trigger the OnChange handler), the number of rows in the gallery (which controls the number of text inputs) is updated accordingly.

    Notice that unless you control the variable you should probably cap the size of the gallery, otherwise you someone may enter a value such as 50000 (the limit of the Sequence function) and your application may become slow since there would be too many controls in the gallery.

    Example of variable controlling gallery size