I am wondering if there is a way to generate dynamic list within PowerApps.
My scenario is if I define a StartYear, I would like the app to generate a collection of years from StartYear to EndYear, or in my specific case, Year(Now()). I am trying to avoid manually hardcoding the years.
Example:
StartYear = 2017
CollectionYear would contain:
then when New Years rolls around, 2020 would be included in the list.
This would be tough to do in PowerApps, but could easily be done in a Flow attached to the PowerApp. Then return the collection to PowerApps.
The Flow -
Hi @itsmeqp
To do this with PowerApps
First create a collection - this would be the hardcoding part
Here you can go upto 100 based on the number of years difference between todays year and the year user enters
So if you think it would be max 50 - then below array should go to 50
ClearCollect(ColNum,{Val:0},{Val:1},{Val:2},{Val:3},{Val:4},{Val:5},{Val:6},{Val:7},{Val:8},{Val:9},{Val:10})
Execute the above on App On Start
Then
To get the years collection
Clear(colYears);ForAll(ColNum,If(Val<=(Year(Now())-2017),Collect(colYears,{Years:Year(Now())-Val})))
where 2017 - can be replaced by the data (numeric) that user enters
--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
No prob.
1. On App start set a variable to your start date. Add variable to collection.
2. Add a timer, OnStart increment your variable and add to collection.
3. Timer repeat If( var_StartYear = Year(Today()), false, true)
4. Hide Timer.
EDIT 5. Timer autoStart needs to be set as well If( var_StartYear = Year(Today()), false, true) or it will keep counting.
A variation of this found here:
https://powerusers.microsoft.com/t5/News-Announcements/How-to-do-ForEach-or-Do-while-loops-in-power-...
User | Count |
---|---|
195 | |
125 | |
88 | |
48 | |
42 |
User | Count |
---|---|
280 | |
163 | |
138 | |
81 | |
76 |