Hello,
I'm following steps on how to create a collection in the docs.microsoft.com module called Use basic formulas to make better Power Apps canvas apps (here). It does not specifically say but it's implied that I use a Data table to create the collection. When following the steps I get the following error: "Behavior function in a non-behavior property. You can't use this property to change values elsewhere in the app."
My question is, am I doing something wrong or is there a problem with the module?
Thank you,
DT
Solved! Go to Solution.
Hi @DT69
You are mistaken regarding how to use a datatable. A datatable is a control that allows you to examine the data that already exists in a table or collection. To create a table from raw data, you can use the Table() function like in the example in the documentation. Once the data is created it is stored in a temporary file called a collection by wrapping the Table in a Collect() or ClearCollect() function. In the example below Collect is used to store the data and the collection is named mydessert. but you could name it anything you want. Remember collections exist only in memory and are erased when the app is closed.
Collect(mydessert, Table({Name: "Chocolate", Price: "$ 3.95", 'Quantity on Hand':
12, 'Quantity on Order': 10}, {Name: "Bread", Price: "$ 4.95",
'Quantity on Hand': 34, 'Quantity on Order': 0}, {Name: "Water",
Price: "$ 1.95", 'Quantity on Hand': 10, 'Quantity on Order':
10})
To execute the formula, place it in the OnSelect property of a button or icon. When you push it, it creates the collection from the data in the table. Then, when the button is pushed a collection called mydessert is created from the data. To view it, put a datatable or gallery control on the screen and set the Items property to: mydessert and you should see the following.
Hi @DT69 ,
Based on the issue that you mentioned, I think there is something wrong with location where you put your Collect or ClearCollect function in your canvas app.
The Collect function or the ClearCollect function is a behavior function, which could not be used within Non-behavior property of a control. On your side, you should put your Collect function or ClearCollect function within Behavior property of a control. e.g. OnSelect property of a button.
More details about behavior formula in PowerApps, please check the following article:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-formulas-in-depth
More details about usage of collection in PowerApps, please check the following article:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/create-update-collection
On your side, please add a button control in your app, set the OnSelect property to following:
ClearCollect(
Collection1,
{Name: "User1", Age: 30},
{Name: "User2", Age35}
)
or
Collect(
Collection1,
{Name: "User1", Age: 30},
{Name: "User2", Age35}
)
Please take a try with above solution, check if the issue is solved.
Best regards,
Hi @DT69
You are mistaken regarding how to use a datatable. A datatable is a control that allows you to examine the data that already exists in a table or collection. To create a table from raw data, you can use the Table() function like in the example in the documentation. Once the data is created it is stored in a temporary file called a collection by wrapping the Table in a Collect() or ClearCollect() function. In the example below Collect is used to store the data and the collection is named mydessert. but you could name it anything you want. Remember collections exist only in memory and are erased when the app is closed.
Collect(mydessert, Table({Name: "Chocolate", Price: "$ 3.95", 'Quantity on Hand':
12, 'Quantity on Order': 10}, {Name: "Bread", Price: "$ 4.95",
'Quantity on Hand': 34, 'Quantity on Order': 0}, {Name: "Water",
Price: "$ 1.95", 'Quantity on Hand': 10, 'Quantity on Order':
10})
To execute the formula, place it in the OnSelect property of a button or icon. When you push it, it creates the collection from the data in the table. Then, when the button is pushed a collection called mydessert is created from the data. To view it, put a datatable or gallery control on the screen and set the Items property to: mydessert and you should see the following.
Hi @DT69 ,
Based on the issue that you mentioned, I think there is something wrong with location where you put your Collect or ClearCollect function in your canvas app.
The Collect function or the ClearCollect function is a behavior function, which could not be used within Non-behavior property of a control. On your side, you should put your Collect function or ClearCollect function within Behavior property of a control. e.g. OnSelect property of a button.
More details about behavior formula in PowerApps, please check the following article:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-formulas-in-depth
More details about usage of collection in PowerApps, please check the following article:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/create-update-collection
On your side, please add a button control in your app, set the OnSelect property to following:
ClearCollect(
Collection1,
{Name: "User1", Age: 30},
{Name: "User2", Age35}
)
or
Collect(
Collection1,
{Name: "User1", Age: 30},
{Name: "User2", Age35}
)
Please take a try with above solution, check if the issue is solved.
Best regards,
That makes complete sense. It appears that the course leaves out some detail. The articles you provided are also helpful.
Best,
DT
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
15 | |
10 | |
7 | |
4 | |
3 |
User | Count |
---|---|
23 | |
15 | |
13 | |
9 | |
9 |