cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Wapfunz
Level: Powered On

collections - creating at start to use for latter calculations.

Hello,

 

Just checking my understanding and hopefully getting corrections to my lack of knowledge.

Senario: I have 160 datacards that contain radio buttons - 160 radio buttons that can have a value of Yes/No/NA.

When the screen opens can I create a Collections variable  - Onvisible(I am guessing) can I place something like:

Collect(AllButtons, 'rbtn1.1'.value, 'rbtn1.2'.value, 'rbtn2.1'.value,'rbtn2.2'.value,..............,'rbtn16.20'.value)

 

Then use this collection to count those that are not blank (have a value).

Count how many have a value of yes

Count how many are "Not Applicable"

And then create a percentage of yes to how many have value

 

What happens (assuming I am on the right track) when the screen is submitted with all its data to the sharepoint list?

Does the collection disappear on closing/submit for the next time the screen is open, or do I need to clear the collection on submit?

 

Thank you.

5 REPLIES 5
Dawidvh
Level 10

Re: collections - creating at start to use for latter calculations.

Hi @Wapfunz

 

It sounds like using a local collection for the datasource, and not only to store the values of the individual cards, might be the answer.

 

You could use the following onVisible to create the new Question records.

 

Collect(localQuestions,

    {question:"Did you do?",answer:"No"},

    {question:"Did you remember?",answer:"No"},

    {question:"Did you forget?",answer:"No"},

    {question:"Did you take?",answer:"No"},

    {question:"Did you eat?",answer:"No"}

)

 

 

This will then create a collection which you can use in a gallery with text controls to display the questions, and radio or drop down controls to give the user an opportunity to give an answer.

 

This will be great for app performance as it doesn't have to load 160 controls, and it will also not limit to you questions. If you want to add or remove questions in future, you don't have to add or reomve controls to the app.

 

To update the information to SharePoint you can use Collect(SharePointList,localQuestions) which will create new list entries if the columns are IDENTICAL. (Dont use lookup or choice columns in the SharePoint list as this will complicate the updating, unless you are very familiar with this complication)

 

To load existing questions from SharePoint you can do Collect(localAnswers,SharePointList)

 

To count the Yes\No\NA answers you can simply use the following in a text label

CountRows(Filter(localQuestions,answer="Yes"))
CountRows(Filter(localQuestions,answer="No"))
CountRows(Filter(localQuestions,answer="NA"))

 

There are various other things to keep in mind, but let me know if the above makes sense to see what else we can help with.

 

twitter: @dawidvh

youTube: https://www.youtube.com/channel/UCIMe_ErQZP5chbI9UyW0xLw

>>If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions.<<

Highlighted
Wapfunz
Level: Powered On

Re: collections - creating at start to use for latter calculations.

Thank you for the reply and help. My apology forslow  replying as long weekend here in NZ

Each of the 160 radio buttons will have a different question attached to them.

e.g. seems rbtn numbering out of step with column and card I assume becuae of edit card screen creation?

 

rbtn5_9 is attched to card 5.4_Emergency Lighting where applicable is functioning?

Answers yes/No/Na

This is column 5.4_EmergencyOp

 

rbtn6_7 is attched to Card 6.7_Where Aplicable staiurs and risers kept clear?

answers Yes/No/Na

This is column 6.7_StairClear

 

Now here it can get different

rbtn6_34 is attched to card 6.17_Is the car park free of any safety concerns?

Answer Safe/At Risk/NA

This column 6.17_CarPark

 

Only 5 of the radio buttons can have an answer of Safe/At Risk/NA

The other 155 are Yes/No/NA

 

So each Radio has a different question.

Not clear on  how to action:

Collect(localQuestions,

    {question:"Did you do?",answer:"No"},

    {question:"Did you remember?",answer:"No"},

    {question:"Did you forget?",answer:"No"},

    {question:"Did you take?",answer:"No"},

    {question:"Did you eat?",answer:"No"})

Thank you.

Super User
Super User

Re: collections - creating at start to use for latter calculations.

Hi @Wapfunz,

In designing an app for surveys, you can take the approach above as a one off but good model for designing different surveys that would achieve maximal flexibility and be scalable, I would recommend the following 4 list design:Capture.PNG

 It would enable you to add additional questions, customize your answers and create multiple surveys using stored questions and answers. 

HadynM
Level 8

Re: collections - creating at start to use for latter calculations.

Hi @Wapfunz

There is a great video from Paul Culmsee ( @paul_culmsee ) that outlines a pattern for an audit app, which sounds similar to what you are trying to achieve.

https://www.youtube.com/watch?v=CSgYBGKNNGk

Cheers

Hadyn

Wapfunz
Level: Powered On

Re: collections - creating at start to use for latter calculations - Part 2.

Thank you all,

Still in limbo - nowever.

What I have is an existing SharePoint list - so not creating a new audit or survey - and am converting an infopath form to powerapps.

I need to create a collectrion of the 160 odd RadioButtons - I fugure to do what I want in counting answers.

How many in total filled.

How many total are Yes or Safe

How manyin total are Not Applicable.

 

I figure I have to create a collection - possibly at the start - so as each radio button is selected the result is showen in real time in a label. This value is also collected and sent when form is uploaded to the SharePoint list.

 

Any help appreciated.

What I have so far thought is as follows: Each button is related as follows:

 

rbtn5_9 is attched to card 5.4_Emergency Lighting where applicable is functioning?

Answers yes/No/Na

This is column 5.4_EmergencyOp

 

rbtn6_7 is attched to Card 6.7_Where Aplicable staiurs and risers kept clear?

answers Yes/No/Na

This is column 6.7_StairClear

 

Now here it can get different

rbtn6_34 is attched to card 6.17_Is the car park free of any safety concerns?

Answer Safe/At Risk/NA

This column 6.17_CarPark

 

Collection(AllButtons,rbtn1_4.selected.value,rbtn1_5.selected.value,rbtn1_6.selected.value,rbtn2_16.selected.value,rbtn2_17.selected.value,rbtn2_18.selected.value,rbtn2_19.selected.value,rbtn2_20.selected.value,rbtn2_21.selected.value,rbtn2_22_.selected.value,rbtn2_23.selected.value,rbtn2_24.selected.value,rbtn2_25.selected.value,rbtn2_26.selected.value,rbtn2_27.selected.value,rbtn2_28.selected.value,rbtn2_29.selected.value,rbtn2_30.selected.value,rbtn3_5.selected.value,rbtn3_6.selected.value,rbtn3_7.selected.value,rbtn3_8.selected.value,rbtn4_8.selected.value,rbtn4_9.selected.value,rbtn4_10.selected.value,rbtn4_11.selected.value,rbtn4_12.selected.value,rbtn4_13.selected.value,rbtn4_14.selected.value,...............)

 

How would one make a collection of the 160 radio buttons?

How do I then filter out Yes, NA and total selected?

 

Ta - even loking at Shane Youngs video's on collection does not quite give me  aclue.

 

 

 

 

 

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 218 members 4,129 guests
Please welcome our newest community members: