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
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (4,994)