Is it possible to have a dynamic variable that is dependent on the nth record it is in?
To explain:
I have a Gallery that shows records, each record has a different "Added Date and time".
I want to create a countdown against each record which displays the minutes and seconds left until 15 minutes after is was added.
i.e record 1 was added at 12:00 , current time is 12:05 , countdown would show 00:10:00 (Ten minutes left)
To generate the values needed to create the countdowns I have a timer with the duration of 1000 ms (1 sec) that repeats and does the below ontimerend (it works out the difference between when the record was added and now in ms)
UpdateContext( { Countdowns:{ Countdown1 : DateDiff(DateTimeValue(Text(First('DATASOURCE]'.Date_x0020_Added).Date_x0020_Added)),Now(),Milliseconds),Countdown2 : DateDiff(DateTimeValue(Text(Last(FirstN('DATASOURCE]'.Date_x0020_Added,2)).Date_x0020_Added)),Now(),Milliseconds) }} )
This creates the variable "countdowns" with both countdown1 and countdown2 retrieving their values from selected (1st & 2nd) records, achieved by using the "First" and a "Last(FirstN" functions to select the correct record. This will be expanded for the 3rd 4th etc when I work out the below issue.
So this works well , however i'm now not sure how to call the variables in the respective record.
What I want to say in the label text property in each record (that will be the countdown) is "If i'm the first record in the gallery my text property should be Countdown1" and "If i'm the Second record in the gallery my text property should be Countdown2".
So I need to call the correct variable dependant on which record "I" am.
I really hope this makes sense.
Alternatively if you can think of a different way of achieving this requirement please let me know.
To be honest this is were a foreach function would come in handy.
As always any help would be greatly appreciated!
Thanks!
Hi @SamPhillips,
Please consider take use of AddColumns() function to create a collection with a CountDown column added to the original data source, better with the Primary Key Renamed to another value, for example, rename the ID field to CID.
So the structure should be:
ClearCollect(Temp, AddColumns(RenameColumns(DataSource, "ID", "CID"), "CountDown",CountDownFormula ))
Once collection is generated, we could take use of the ID and the CID to lookup the CountDown value for each record.
For example:
CountDownLabel within the Gallery:
Lookup(Temp, CID=ThisItem.ID, CounfDown)
Function reference:
Please post back if you need any further help on this.
Regards,
Michael
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
199 | |
71 | |
48 | |
42 | |
30 |
User | Count |
---|---|
264 | |
121 | |
94 | |
89 | |
83 |