cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hector999-0
Regular Visitor

How to loop through columns in a record (row) of a collection using Power Fx language/Formula?

I'm new to Power Apps and I'm trying to loop(1) through a collection and then loop(2) through a single row's columns. Within a ForAll, you cannot increment a column's name to loop through the columns of a row.  Is there a way to do this using formula language? If not, can I use a flow to achieve this process? If so, can you share some examples with me?  Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Hector999-0 :

I've made a test for your reference:

1\I assume there is a collection :

ClearCollect(
   thecollection,
   {column1:1,Column2:2,Column3:3},
   {column1:4,Column2:5,Column3:6}
)

 2\Create a button and set it's OnSelelct property to:

Clear(TheResult);
ForAll(
    thecollection,
    ForAll(
        Split(
            Substitute(Substitute(JSON(ThisRecord),"{",""),"}",""),
            ","
        ),
        Collect(
            TheResult,
            Last(Split(Result,":").Result
            )
        )
    )
)

vbofengmsft_0-1627954486690.png

Note:This method is only applicable to specific collections with a simple structure

Best Regards,

Bof

 

View solution in original post

4 REPLIES 4
v-bofeng-msft
Community Support
Community Support

Hi @Hector999-0 :

I've made a test for your reference:

1\I assume there is a collection :

ClearCollect(
   thecollection,
   {column1:1,Column2:2,Column3:3},
   {column1:4,Column2:5,Column3:6}
)

 2\Create a button and set it's OnSelelct property to:

Clear(TheResult);
ForAll(
    thecollection,
    ForAll(
        Split(
            Substitute(Substitute(JSON(ThisRecord),"{",""),"}",""),
            ","
        ),
        Collect(
            TheResult,
            Last(Split(Result,":").Result
            )
        )
    )
)

vbofengmsft_0-1627954486690.png

Note:This method is only applicable to specific collections with a simple structure

Best Regards,

Bof

 

Thank you so much for helping me in getting the formula you suggested.  It worked fine.  Now I was wondering if you can help me in figure out a bit complicated problem.  Should I post this on a new post or can I posted in a reply? Let me know how to proceed.  Thank you again!

Hi @Hector999-0 :

I suggest you consider creating a new thread.(Doing so may get more help and benefit other users in the forum with similar problems)

Best Regards,

Bof

Can I get your opinion on the recent post I made. Is called

"I need your assistance in developing a formula for..."  I want to know if a formula can be used to solve the problem or a flow.  Thank you.

Helpful resources

Announcements
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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