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
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,848)