Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

How to get record before and after in forall loop powerapps

I am trying to run a function that returns a table with a corresponding date index and date text. This is so that I can display the information in a tutorial screen. However, I am confused on how to access to the previous record. Here is my pseudocode:

```
ForAll( Tweets (sorted by crf1d_date_index),
If(the record IS NOT the LAST record,
If('crf1d_date_index' != 'crf1d_date_index' of the NEXT record,
{
Step: crf1d_date_index,
Text: crf1d_tweet_time
}
)
)

If(the record IS the LAST record,
If('crf1d_date_index' != 'crf1d_date_index' of the PREVIOUS record),
{
Step: crf1d_date_index,
Text: crf1d_tweet_time
}
)

)
```

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

Hi @jaugustin12 ,

 

My first idea was to add an Index column. Looking at the way to do that, also involving a ForAll() loop, perhaps you can use this solution and combine it with your requirements:

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/Adding-an-index-column-to-a-collection/td-p/...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors