Hi,
In a screen there are 10 questions, and user will select, Yes or No radio buttons. Upon clicking on submit button, coverages associated to the questions should be shown in the next screen based on configuration table.
Coverages are based on scenarios like, show Coverage4 if Q1 is Yes and Q2 is No. So created a configuration table accordingly like below:
Configuration table:
SCN-1 | Q1 | Yes | Cov4 |
SCN-1 | Q2 | No | Cov4 |
SCN-2 | Q2 | Yes | Cov5 |
SCN-2 | Q3 | No | Cov5 |
SCN-3 | Q3 | Yes | Cov6 |
SCN-4 | Q4 | Yes | Cov7 |
SCN-4 | Q5 | Yes | Cov7 |
Implementation: On App Start, created a collection to hold the configuration table.
ClearCollect(configTable, ConfigurationTables);
ClearCollect(uniqueScenariosColl, Distinct(configTable,Scenarios));
uniqueScenarioColl = ["SCN-1","SCN-2","SCN-3",...........]
Now on click on submit button, saved user's response in collection like below:
userResponseCol = [{q="Q01",r="Yes"},{q="Q02",r="No"},{q="Q03",r="No"}]
I am not able to merge the below two ForAll conditions. logic is loop all scenarios, get first scenario conditions, here Q1 is Yes and Q2 is No, check if two records are in userResponseColl, only then add the Cov4 to the finalCoverageCollection, then check second scenario and go on..
ForAll(uniqueScenariosColl,Collect(scenarioColl,Filter(configTable,Scenarios=Value)));
ForAll(scenarioColl,ForAll(userResponseCol, If(ThisRecord.q= QuestionId And ThisRecord.r = Response,Collect(matchColl,CoverageId))));
If(CountRows(matchColl) = CountRows(scenarioColl),Collect(finalCoverageCollection,matchColl));
Clear(scenarioColl); Clear(matchColl);
Appreciate your help here.
Solved! Go to Solution.
Here a method to get what you want - ie Coverage values - but you may need to adjust it slightly?
App OnStart
// App OnStart
ClearCollect(
configTable,
{Scenario: "SCN-1", Question: "Q1", QResponse: "Yes", Coverage: "Cov4"},
{Scenario: "SCN-1", Question: "Q2", QResponse: "No", Coverage: "Cov4"},
{Scenario: "SCN-2", Question: "Q2", QResponse: "Yes", Coverage: "Cov5"},
{Scenario: "SCN-2", Question: "Q3", QResponse: "No", Coverage: "Cov5"},
{Scenario: "SCN-3", Question: "Q3", QResponse: "Yes", Coverage: "Cov6"},
{Scenario: "SCN-4", Question: "Q4", QResponse: "Yes", Coverage: "Cov7"},
{Scenario: "SCN-4", Question: "Q5", QResponse: "Yes", Coverage: "Cov7"}
);
// responses table with 2 extra columns
ClearCollect(
responsesInitial,
AddColumns(configTable, "CoverageResponse", "", "ShowValue", "" )
);
I've added two columns to the original configTable in a new collection that can be used below
Question gallery
Distinct(configTable, Question).Result
Yes/No Radio button OnChange
UpdateIf(
responsesInitial,
Question = ThisItem.Result ,
{
CoverageResponse: rd5.Selected.Value
}
);
Submit button
ClearCollect(
userResponseCol,
ForAll(
responsesInitial,
{
Scenario: Scenario,
Question: Question,
QResponse: QResponse,
Coverage: Coverage,
CoverageResponse: CoverageResponse,
ShowValue: If(QResponse = CoverageResponse, 1,0)
}
)
);
Clear(finalCoverageCollection);
ForAll(
Distinct(userResponseCol, Scenario) As ds,
If(
CountRows( Filter(userResponseCol, Scenario = ds.Result)) = Sum( Filter(userResponseCol, Scenario = ds.Result),ShowValue ),
Collect(
finalCoverageCollection,
LookUp( userResponseCol, Scenario = ds.Result, Coverage)
)
)
)
Examples of use using your data above
Hopefully this makes sense and gets you what you need?
Try using As to separate off your 2 collection in the second ForAll(), ie
ForAll(
scenarioColl As scCol,
ForAll(
userResponseCol As urCol,
….
)
Then use scCol and urCol to reference the different collections. Using ThisRecord doesn’t usually work inside 2 x ForAll statements
Thanks for the response. Whatever you have mentioned i.e., second ForAll is working fine, what i am looking for - include the second ForAll within first ForAll and make it work.
First loop: ForAll(uniqueScenariosColl,Collect(scenarioColl,Filter(configTable,Scenarios=Value)));
Second ForAll: ForAll(scenarioColl,ForAll(userResponseCol, If(ThisRecord.q= QuestionId And ThisRecord.r = Response,Collect(matchColl,CoverageId))));
merge these two and also need to include below two statements in second ForAll.
If(CountRows(matchColl) = CountRows(scenarioColl),Collect(finalCoverageCollection,matchColl));
Clear(scenarioColl); Clear(matchColl);
Here a method to get what you want - ie Coverage values - but you may need to adjust it slightly?
App OnStart
// App OnStart
ClearCollect(
configTable,
{Scenario: "SCN-1", Question: "Q1", QResponse: "Yes", Coverage: "Cov4"},
{Scenario: "SCN-1", Question: "Q2", QResponse: "No", Coverage: "Cov4"},
{Scenario: "SCN-2", Question: "Q2", QResponse: "Yes", Coverage: "Cov5"},
{Scenario: "SCN-2", Question: "Q3", QResponse: "No", Coverage: "Cov5"},
{Scenario: "SCN-3", Question: "Q3", QResponse: "Yes", Coverage: "Cov6"},
{Scenario: "SCN-4", Question: "Q4", QResponse: "Yes", Coverage: "Cov7"},
{Scenario: "SCN-4", Question: "Q5", QResponse: "Yes", Coverage: "Cov7"}
);
// responses table with 2 extra columns
ClearCollect(
responsesInitial,
AddColumns(configTable, "CoverageResponse", "", "ShowValue", "" )
);
I've added two columns to the original configTable in a new collection that can be used below
Question gallery
Distinct(configTable, Question).Result
Yes/No Radio button OnChange
UpdateIf(
responsesInitial,
Question = ThisItem.Result ,
{
CoverageResponse: rd5.Selected.Value
}
);
Submit button
ClearCollect(
userResponseCol,
ForAll(
responsesInitial,
{
Scenario: Scenario,
Question: Question,
QResponse: QResponse,
Coverage: Coverage,
CoverageResponse: CoverageResponse,
ShowValue: If(QResponse = CoverageResponse, 1,0)
}
)
);
Clear(finalCoverageCollection);
ForAll(
Distinct(userResponseCol, Scenario) As ds,
If(
CountRows( Filter(userResponseCol, Scenario = ds.Result)) = Sum( Filter(userResponseCol, Scenario = ds.Result),ShowValue ),
Collect(
finalCoverageCollection,
LookUp( userResponseCol, Scenario = ds.Result, Coverage)
)
)
)
Examples of use using your data above
Hopefully this makes sense and gets you what you need?
Thank you @EddieE for the response. I solved my issue by merging the loops like said above, and really liked your approach as well. Appreciate your help.
User | Count |
---|---|
162 | |
91 | |
68 | |
64 | |
63 |
User | Count |
---|---|
211 | |
157 | |
93 | |
81 | |
71 |