cancel
Showing results for
Did you mean:
Continued Contributor

## Loops with multiple collections...

I have a collection of dates...(one row per date) - say 31 days of Jan 2023.

1/1/2023, 1/2/2023, 1/3/2023, etc...
For Each Date I want to add a sequence.. at 15 min increments for each day (in the end from 7:00 AM to 7:00 PM)

``````ForAll(
Sequence(
49,/* how many times to repeat */
420,/* starting time for day in minutes */
15/* repeat every 15 mins */
)
)``````

1/1/2023 7:00 AM, 1/1/2023 7:15 AM, 1/1/2023 7:30 AM, .... 1/2/2023 7:00 AM, 1/2/2023 7:15 AM, 1/2/2023 7:30 AM
For some reason I am struggling with the concept of ForAll here and creating a table that is 31 (days) x 49 (sequences) = 1,519 rows from 2 separate collections.

I'm sorry but I think I've confused myself. Can someone help me get on the right path please. I am more accustomed to 1:1 lookups.

1 ACCEPTED SOLUTION

Accepted Solutions
Multi Super User

Here is the collection of days (of course you can as some dynamic logic to fill the days):

``````ClearCollect(
MyDays,
ForAll(
Sequence(31),
DateValue("12/31/2022"),
Value,
TimeUnit.Days
)
)
);``````

And here is the logic to fill with data (15 min gap from 7:00 AM to 7:00 PM) a new collection starting from the previous collection:

``````ClearCollect(
MyTimeInterval,
Ungroup(
ForAll(
MyDays As _myDaysItem,
{
ByDays: ForAll(
Sequence(49),
{
_myDaysItem.Value,
405 + Value * 15,
TimeUnit.Minutes
)
}
)
}
),
"ByDays"
)
)``````

Hope it helps !

2 REPLIES 2
Multi Super User

Here is the collection of days (of course you can as some dynamic logic to fill the days):

``````ClearCollect(
MyDays,
ForAll(
Sequence(31),
DateValue("12/31/2022"),
Value,
TimeUnit.Days
)
)
);``````

And here is the logic to fill with data (15 min gap from 7:00 AM to 7:00 PM) a new collection starting from the previous collection:

``````ClearCollect(
MyTimeInterval,
Ungroup(
ForAll(
MyDays As _myDaysItem,
{
ByDays: ForAll(
Sequence(49),
{
_myDaysItem.Value,
405 + Value * 15,
TimeUnit.Minutes
)
}
)
}
),
"ByDays"
)
)``````

Hope it helps !

Continued Contributor

Thanks @gabibalaban  I'll let you know how this works out shortly... I think it's the ungroup thing that I was missing.

Announcements

#### Celebrating the May Super User of the Month: Laurens Martens

@LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!

#### Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!