Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

Lookup a collection against a record value

(0) ShareShare
ReportReport
Posted on by 82
Hi,
 
I've been trying to solve the following problem. I have an app that displays 1 question at a time from my database of questions. All questions are mapped to a QuestionID and DifficultyLevel.

I've noticed that sometimes the same question appears. So I have started a collection "ShownQuestions" that records the QuestionID of the questions being displayed.

How can I modify my current code that displays the next question by first seeing if it is being asked previously and if so, display another question.
"
//Set the next question
Set(
    CurrentQuestion, //CurrentQuestion is whats being displayed
    First(
        Shuffle(
            Filter(
                QBANK, //QBANK is my question bank.
                Difficulty = NextDifficulty  //NextDifficulty is how i determine the next difficulty based on a logic.
            )
        )
    )
);
"
 
 
Categories:
  • User_Naami Profile Picture
    User_Naami 82 on at
    Lookup a collection against a record value
    Hi @timl and @Spong Ye both the solutions does not work.

    It displays the first question but then the second question just returns blank.
  • Suggested answer
    timl Profile Picture
    timl 32,870 on at
    Lookup a collection against a record value
    Hi User_Naami 
     
    Here's some alternative syntax that should also work.
    Set(
        CurrentQuestion, 
        First(
            Shuffle(
                Filter(
                    QBANK, // QBANK is your question bank
                    Difficulty = NextDifficulty,
                    Not(QuestionID in ShownQuestions.QuestionID) 
                )
            )
        )
    );
     
  • Suggested answer
    SpongYe Profile Picture
    SpongYe 5,358 on at
    Lookup a collection against a record value
    Hi,
     
    Store the questions that are shown in the ShownQuestions collection.
    Then, you can check if a question is already in the collection
     
     
    // Set the next question
    Set(
        CurrentQuestion, // CurrentQuestion is what's being displayed
        First(
            Shuffle(
                Filter(
                    QBANK, // QBANK is your question bank
                    Difficulty = NextDifficulty && // NextDifficulty is how you determine the next difficulty based on a logic
                    !IsBlank(LookUp(ShownQuestions, QuestionID = QuestionID)) // Check if the question has already been shown
                )
            )
        )
    );
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

End of Year Newsletter…

End of Year Community Newsletter…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #11 New Opportunities…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,609

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,420

Leaderboard