Hi,
I have a lengthy self-assessment set up in a PowerApp, populating a Sharepoint list
Many of the questions are 'Choice' columns in the SharePoint list, and I am using forms with drop-down datacards in PowerApps.
Currently, I am using ...Selected.Value in If statements to assign a score for that question to a Context Variable that adds to a total global variable.
The flaw with this approach is if I don't have the EXACT text as defined in the SharePoint list's choice column in quotes, it isn't going to assign a score, leaving much margin for error. In addition, I am likely to have to edit the responses after user feedback, and this is going to generate a lot of extra work.
Is there a way of referencing, in, for example, a four-option choice as a drop-down, whether it is the first, second, third, and fourth value, irrespective of its actual value?
So instead of:
If(Dropdown1Q22.Selected.Value = "I wait until someone shows me how to use it",UpdateContext({ScreenScore:1}));
If(Dropdown1Q22.Selected.Value = "I commit time to getting familiar with it",UpdateContext({ScreenScore:2}));
If(Dropdown1Q22.Selected.Value = "I am confident enough to use the software and look for online help if needed",UpdateContext({ScreenScore:3}));
If(Dropdown1Q22.Selected.Value = "When software is updated, I will start by looking at and evaluating new features",UpdateContext({ScreenScore:4}));
I could have something along the lines of:
If(Dropdown1Q22.Selected= 1,UpdateContext({ScreenScore:1}));
If(Dropdown1Q22.Selected= 2,UpdateContext({ScreenScore:2}));
If(Dropdown1Q22.Selected= 3,UpdateContext({ScreenScore:3}));
If(Dropdown1Q22.Selected= 4,UpdateContext({ScreenScore:4}));
...so the If statement is more robust?
Thanks in advance.
Solved! Go to Solution.
Hi @JamFestival :
Please try:
Clear(TheCount);
ForAll(
Choices ([@POC].'When I need to use new software, or software I use is updated: '),
If(
Dropdown1Q22.Selected.Value=Value,
Collect(TheCount,{Value:1},{Value:0}),
IsBlank(LookUp(TheCount,Value=0)),
Collect(TheCount,{Value:1}),
Collect(TheCount,{Value:0})));
UpdateContext({ScreenScore:Sum(TheCount,Value)})
I've made a test for your reference:
Best Regards,
Bof
Please check this approach:
Switch(
Dropdown1Q22.Selected.Id,
1,
UpdateContext({ScreenScore:1}),
2,
UpdateContext({ScreenScore:2}),
3,
UpdateContext({ScreenScore:3}),
4,
UpdateContext({ScreenScore:4})
)
Hope it helps !
Thanks.
Unfortunately, it doesn't recognise the '.Id' part.
Please share Dropdown1Q22 - Items property.
It is:
Choices ([@POC].'When I need to use new software, or software I use is updated: ')
POC is the name of the sharepoint list
Hi @JamFestival :
Please try:
Clear(TheCount);
ForAll(
Choices ([@POC].'When I need to use new software, or software I use is updated: '),
If(
Dropdown1Q22.Selected.Value=Value,
Collect(TheCount,{Value:1},{Value:0}),
IsBlank(LookUp(TheCount,Value=0)),
Collect(TheCount,{Value:1}),
Collect(TheCount,{Value:0})));
UpdateContext({ScreenScore:Sum(TheCount,Value)})
I've made a test for your reference:
Best Regards,
Bof
Thank you so much for this advice. I haven't had the opportunity to try it until now, so sorry for the delay in responding. It works flawlessly!
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
197 | |
68 | |
46 | |
41 | |
27 |
User | Count |
---|---|
254 | |
121 | |
84 | |
80 | |
73 |