This shouldn't be so hard! 🤤 I don't have any more hair to pull out.
Here's the situation:
I've got a Dataverse table of questions. That table has a column for the question number. Let's call them "q-1, q-2", etc.
I've got a second Dataverse table that defines question "sets". This table has a multi-select choice column that holds the question numbers I want in that set. For example, I could have a "set" of questions called "qSet-1" (a text column) and the multi-select column value of "q-1, q-3, q-7, q-10"). Those values represent question numbers in the first table. However, there is no Dataverse relationship established. (The question numbers in each question set are set initially by linking the multi-select column to a lookup global choice with all possible values of the question number. If that's important, let's call that global choice, "allPossibleQuestionNumbers").
| SetNumber | Questions (multi-select linked to "allPossibleQuestionNumbers") |
| qSet-1 | q-1,q-3,q-7,q-10 |
| qSet-2 | q-1,q-2,q-5,q-10 |
| qSet-3 | q-2,q-6,q-9,q-11 |
| QuestionNumber | Question | CodeValue |
| q-1 | What is your name? | myCode1 |
| q-2 | What is your age? | myCode2 |
| q-3 | What is your quest? | myCode3 |
| q-4 | Where do you live? | myCode4 |
| <and so on> | <and so on> | <and so on> |
Now, inside Power Apps, I need to select one of the question sets by setting a variable. For example, let's say I've set my variable, "vSelectedSet" to "qSet-1". So far so good.
However, now I need to somehow programmatically create a table in Power Apps of the selected questions (and other data from the questions table) that are part of that set. So, in this example, I need a table like this to be created when the variable is set to qSet-1 (which I plan to do using a "deep link" URL for the app, but I don't think that's important):
| QuestionNumber | Question | CodeValue |
| q-1 | What is your name? | myCode1 |
| q-3 | What is your quest? | myCode3 |
| q-7 | What is your favorite color? | myCode7 |
| q-10 | What is your favorite movie? | myCode10 |
Obviously, if my app with started with a different value for the variable (selecting a different question set), the table above needs the data from those different questions instead.
It seems like the biggest difficulty is in first creating a table, based on the selected set that has the set members in a Power Apps table (or collection). Once that is done, then I need to populate the rest of the table (or collection) with values from the question table.
Using the following, I'm able to get the set members into a text string, but I don't think that is getting me anywhere. I can't find a way to convert that string (vQuestionSetString) into a Power Apps table (or collection):
Set (vSelectedSet, "qSet-1")
Set(vQuestionNumbers, LookUp(QuestionSets, SetNumber = vSelectedSet, Questions));
Set(vQuestionSetString, Concat(vQuestionNumbers, Value & ","));
I've tried coming at this from several different ways, but I just can't seem to make it work.