cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Oskarkuus
Super User
Super User

How to collect data from textinputs?

I have this code:

 

ClearCollect(
    colText1;
    ForAll(
        Split(TextInput1.Text; Char(10));
        {
            Text1: Result            
            
        })
        
        
)

 

 

It works great. It takes all values from textinput1 and create a collection, one row for each new row in the textinput box.

 

But now i want to duplicate this code and at the same time add data from another textinput.

So i did this:

 

Clear(colText1);;
ClearCollect(
    colText1;
    ForAll(
        Split(TextInput1.Text; Char(10));
        {
            Text1: Result            
            
        });

        ForAll(
        Split(TextInput1_1.Text; Char(10));
        {
            Text2: Result            
            
        })
        
        
)

 

 

But then the collection looks like this.

This is not the result i am after. I want them to be side by side. So i can with one button collect several textinputs to one collection and keep the order that the textinputs have.

 

Oskarkuus_0-1619341856466.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Oskarkuus ,

This is not nearly as easy as you might think and I answered a similar question a week or so ago and ended up writing a blog on it. Note I have free-typed this, so you might have to clean up commas/brackets etc, but the structure you need is below

Clear(colText1);;
With(
   {
      wList:
      ForAll(
         Split(
            TextInput1.Text; 
            Char(10)
         );
         {Text1: Result}
      )
   };
   Collect(
      colText1;
      Patch(
         Last(
            FirstN(
               wList;
               Value
            )
         );
         {RowNo1: Value}
      )
   )
);;
Clear(colText2);;
With(
   {
      wList:
      ForAll(
         Split(
            TextInput1_1.Text; 
            Char(10)
         );
         {Text2: Result}
      )
   };
   Collect(
      colText2;
      Patch(
         Last(
            FirstN(
               wList;
               Value
            )
         );
         {RowNo2: Value}
      )
   )
);;
Clear(colText3);;
Collect(
   colText3;
   AddColumns(
      colText1;
      "Text2";
      LookUp(
         colText2;
         RowNo2 = RowNo1
      ).Text2
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

1 REPLY 1
WarrenBelz
Super User
Super User

Hi @Oskarkuus ,

This is not nearly as easy as you might think and I answered a similar question a week or so ago and ended up writing a blog on it. Note I have free-typed this, so you might have to clean up commas/brackets etc, but the structure you need is below

Clear(colText1);;
With(
   {
      wList:
      ForAll(
         Split(
            TextInput1.Text; 
            Char(10)
         );
         {Text1: Result}
      )
   };
   Collect(
      colText1;
      Patch(
         Last(
            FirstN(
               wList;
               Value
            )
         );
         {RowNo1: Value}
      )
   )
);;
Clear(colText2);;
With(
   {
      wList:
      ForAll(
         Split(
            TextInput1_1.Text; 
            Char(10)
         );
         {Text2: Result}
      )
   };
   Collect(
      colText2;
      Patch(
         Last(
            FirstN(
               wList;
               Value
            )
         );
         {RowNo2: Value}
      )
   )
);;
Clear(colText3);;
Collect(
   colText3;
   AddColumns(
      colText1;
      "Text2";
      LookUp(
         colText2;
         RowNo2 = RowNo1
      ).Text2
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,163)