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 Apps Africa Challenge 2022

Power Apps Africa Challenge

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

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,229)