cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akosbanar
Resolver I
Resolver I

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 Specialist
Solution Specialist

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

 

KvB1
Solution Specialist
Solution Specialist

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 Specialist
Solution Specialist

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}
)

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,921)