cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
halifaxious
Helper II
Helper II

can a collection column be typeless?

I want to create a collection, responseCollection with 2 columns: question and answers. The question column will contain a reference to a record in another table. The answers column will contain the selected items from the list input, answerList.

 

This would be simple if a user could visit a question only once. I'd just create the collection when the first question was answered.

Collect(ResponseCollection,{question:currentQuestion,selections:Self.SelectedItems});

But a user is allowed to edit their answers and return to questions as often as they like. New answers need to replace the old answers.

 

So I thought I'd create responseCollection with all the questions already in it and an empty answer column.

ClearCollect(ResponseCollection,{question:Questions, selections: Blank()})

 

Then I'd just patch the collection based on the current question in answerList.OnChange.

Patch(ResponseCollection,Filter(ResponseCollection,question=currentQuestion),{selections:Self.SelectedItems}) //nope!

But Patch will only allow me to add Blank() to the answer column.

 

So, how can I create a patchable collection with an empty column that can hold SelectedItems from a list box?

1 ACCEPTED SOLUTION

Accepted Solutions

It turned out that I needed to set my empty column to Table()

ClearCollect(ResponseCollection,{question:Questions, selections: Table()})

Then I could successfully add data to it.

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@halifaxious 

You can use Blank on a column and then later assign it a specific type.  You cannot, however, change the type.  In other words, you could not in one place assign a table and in another a record or a simple type.

Your problem comes from your formula.

It should be this:

Patch(ResponseCollection, LookUp(ResponseCollection, question=currentQuestion),
   {selections:Self.SelectedItems}
) 

Or:

UpdateIf(ResponseCollection, question=currentQuestion,
   {selections:Self.SelectedItems}
) 

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

It turned out that I needed to set my empty column to Table()

ClearCollect(ResponseCollection,{question:Questions, selections: Table()})

Then I could successfully add data to it.

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,824)