cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akosbanar
Advocate IV
Advocate IV

Table with Variables in ClearCollet

Dear All,

 

I would like to create a collection where I store data from different Inputs (TextInput, Dropdown).

First, I created Variable tables for the Input elements, later I tried to collect them but it is not working but I followed the Microsoft offers from the Documentation page.  

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-table-shaping

akosbanar_0-1627551334290.png

 

 

Set(
    Business_owner,
    Table(
        {
            Answer: Business_owner_TextInput.Text,
            Comment: Business_owner_Comment_TextInput.Text
        }
    )
);
Set(
    Related_Project_Dd,
    Table(
        {
            Answer: Related_Project_Dropdown.Selected,
            Comment: Related_Project_Comment_TextInput.Text
        }
    )
);
ClearCollect(
    Detail_Table, 
 	Table(
    	{ Answers: Business_owner.Answer, Comments: Business_owner.Comment }, 
        { Answers: Related_Project_Dd.Answer, Comments: Related_Project_Dd.Comment }
 	)
 )

 

 

 Thank you for your help in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you very much for your help.

The solution is similar what you suggested.

ClearCollect(
    Detail_Table,
    	{ Answers: First(Business_owner).Answer, Comments: First(Business_owner).Comment },
        { Answers: First(Related_Project_Dd).Answer.SourceTableOfTheDropdown, Comments: First(Related_Project_Dd).Comment}
)

View solution in original post

6 REPLIES 6
KvB1
Solution Sage
Solution Sage

You have set your variables as a table. In your clearcollect formula, you grab the specified column of that variable, but it will still be a table. The fields in your collection will therefore be populated by a 1x1 table since there is only one row in your variable.

 

Set(
    Business_owner,
    Table(
        {
            Answer: Business_owner_TextInput.Text,
            Comment: Business_owner_Comment_TextInput.Text
        }
    )
);
Set(
    Related_Project_Dd,
    Table(
        {
            Answer: Related_Project_Dropdown.Selected,
            Comment: Related_Project_Comment_TextInput.Text
        }
    )
);
ClearCollect(
    Detail_Table, 
 	Table(
    	{ Answers: First(Business_owner).Answer, Comments: First(Business_owner).Comment }, 
        { Answers: First(Related_Project_Dd).Answer, Comments: First(Related_Project_Dd).Comment }
 	)
 )

Here you specify that the first row of the table in your has to be grabbed, and that the specified column has to populate the relevant field in your collection.

Hello,

Thank you for your reply.

Unfortunately, it is still not working.

akosbanar_0-1627557096443.png

 

What is the items property of your dropdown? If that is a table as well, then you need to further specify which value to grab from it. If you add a . after 

 

First(Related_Project_Dd).Answer

 

Do any suggestions come up?

Yes, it is a table in a collection what contains two values, yes and no.

KvB1
Solution Sage
Solution Sage

Try

Set(
    Business_owner,
    Table(
        {
            Answer: Business_owner_TextInput.Text,
            Comment: Business_owner_Comment_TextInput.Text
        }
    )
);
Set(
    Related_Project_Dd,
    Table(
        {
            Answer: Related_Project_Dropdown.Selected,
            Comment: Related_Project_Comment_TextInput.Text
        }
    )
);
ClearCollect(
    Detail_Table, 
 	Table(
    	{ Answers: First(Business_owner).Answer.Value, Comments: First(Business_owner).Comment }, 
        { Answers: First(Related_Project_Dd).Answer.Value, Comments: First(Related_Project_Dd).Comment }
 	)
 )

If you specified the column name for the collection that is in the Items property of your dropdown, replace "Value" by that (it should suggest it)

Thank you very much for your help.

The solution is similar what you suggested.

ClearCollect(
    Detail_Table,
    	{ Answers: First(Business_owner).Answer, Comments: First(Business_owner).Comment },
        { Answers: First(Related_Project_Dd).Answer.SourceTableOfTheDropdown, Comments: First(Related_Project_Dd).Comment}
)

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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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
Users online (2,017)