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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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