cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LeeB_CDN
Helper III
Helper III

Multiple ForAll(Sequence) events within Collect or ClearCollect function

Hello, Folks

 

Is there a way to make this syntax work within a ClearCollect, or Collect function? 

ClearCollect(colLocationList, 
ForAll(Sequence(16), {LSD_Values:Text(Value)}), 
ForAll(Sequence(36), {SEC_Values:Text(Value)}),
ForAll(Sequence(126), {TWP_Values:Text(Value)})
);

I'm trying to  collect multiple columns of different sequenced values in one function... This syntax is accepted but only the first column returns values when executed: 

SequenceCollection.PNG

Any thoughts?

 

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
cwebb365
Super User
Super User

Hmmm, this should work? 

 

ClearCollect(
colLocationList,
ForAll(
Sequence(126),
If(
Value <= 16,
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
If(
Value <= 36,
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
}
)
)
)
)

View solution in original post

cwebb365
Super User
Super User

My Bad, Use this one as the answer. I messed up the edit's, first one did all numbers, just needed blanks in there instead if you haven't figured that out already, here is working code. 

ClearCollect(
colLocationList,
ForAll(
Sequence(126),
If(
Value <= 16,
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
If(
Value <= 36,
{
LSD_Values: "",
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
{
LSD_Values: "",
SEC_Values: "",
TWP_Values: Text(Value)
}
)
)
)
)

 

 

As for the 0's gonna be something in the Text() function I think can handle that let me fiddle. 

View solution in original post

8 REPLIES 8
LeeB_CDN
Helper III
Helper III

Ok, upon further evaluation it looks like the function IS collecting each sequence, but instead of starting at the first row in the collection (for each new column), it is adding the preceding sequence number of empty values into that corresponding column... so SEC_Values column has 16 blank fields before the (36) number sequence starts.. That is unexpected behavior...  Any ideas?  

cwebb365
Super User
Super User

Hmmm, this should work? 

 

ClearCollect(
colLocationList,
ForAll(
Sequence(126),
If(
Value <= 16,
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
If(
Value <= 36,
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
}
)
)
)
)

cwebb365
Super User
Super User

Ops, I mean this 😛 

 

ClearCollect(
colLocationList,
ForAll(
Sequence(126),
If(
Value <= 16,
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
If(
Value <= 36,
{

SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
{

TWP_Values: Text(Value)
}
)
)
)
)

Brilliant @cwebb365 ... Wrapping my brain around this Powerapp syntax is crazy, I appreciate your approach, it worked exceptionally! 

 

Can you think of a way for me to add "0"'s to the TWP_Values record so that double digit #'s would show a single "0" preceding the value, and single digit #'s would show "00" preceding the value?  

Haha... woops I think I jumped the gun... First solution just listed all numbers in each column (to 126) 

Second solution only showed first set of numbers and didn't add the other columns!.. 

cwebb365
Super User
Super User

My Bad, Use this one as the answer. I messed up the edit's, first one did all numbers, just needed blanks in there instead if you haven't figured that out already, here is working code. 

ClearCollect(
colLocationList,
ForAll(
Sequence(126),
If(
Value <= 16,
{
LSD_Values: Text(Value),
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
If(
Value <= 36,
{
LSD_Values: "",
SEC_Values: Text(Value),
TWP_Values: Text(Value)
},
{
LSD_Values: "",
SEC_Values: "",
TWP_Values: Text(Value)
}
)
)
)
)

 

 

As for the 0's gonna be something in the Text() function I think can handle that let me fiddle. 

Ok so for the 0's, use Text(Value,"0#") for the TWP Values. You can do leading 0's, only need it for the first IF statement since after the first group you won't need it in the rest. 

Yes @cwebb365 !! You did it! Thank you so much! That allowed me to filter and add the zeros where required. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,942)