Towards the end of 2020 – a colleague of mine shared a link to this 5 question Power BI Quiz. While the content of the quiz is refreshing in its own right, I was struck by how the report creator (Daniil Maslyuk) was able to track and maintain a user’s score as they navigated from question to question – and ultimately present the total score back at the end:
It’s safe to say that Power BI should not be your go-to tool for creating quizzes. However, I was inspired by Daniil’s quiz to try and figure out how this could be done. I was curious about how to introduce “memory” to a Power BI report – so that a user’s performance could be tracked and carried to the final page (much like it was above).
So let’s consider this problem by building a simple 3 question quiz. Here’s question 1:
Setting up the questions is pretty straight forward:
Draft a question
Add buttons to display an answer
Add a button to navigate to the next question
Add some text boxes to provide feedback if the user is correct or incorrect.
The question at the heart of this post is how do we now keep track of the score as a user selects an answer and then moves between questions and report pages?
While there are a few interesting options to consider: such as a Power Automate flow to add values to the dataset – these may be hindered by the daily refresh limit of 8 (shared capacity) or 48 (premium) when trying to bring new data into the report.
I chose instead to establish ‘memory’ by using a combination of slicers and bookmarks.
Continuing with our first quiz question, each answer button is linked to one of two bookmarks appropriately titled “Correct” or “Incorrect”. These bookmarks are triggers upon a click of each button. Additionally, hidden on each report page – is a slicer to record the points earned:
The “CORRECT” bookmark – is created with the point slicer saved at “1”. Likewise, an incorrect answer choice calls the “INCORRECT” bookmark with the same point slicer saved at “0”. These bookmarks also call up the text box explaining the answer choice as well as a button to navigate to the next question.
Once the slicer is setup – it doesn’t need to be visible on the screen – as it will work all the same when hidden from view.
Now we essentially ‘rinse and repeat’ for question 2 and question 3. Each question requires its own dedicated point slicer and set of bookmarks. The magic in creating ‘memory’ is that these slicers can be synced to other pages in the report. This is evident if when we copy/paste a slicer to a new report page as the following prompt comes up:
Using these synced slicers – we can carry a score from page to page, and ultimately build a Final Summary page that uses all of the slicers to share overall performance. Below is an example summary page with the Question 2 slicer showing. This page contains all 3 point slicers (Q1 and Q3 are hidden from view).
With our points all sitting in synced slicers – how then do we calculate a Total score?
Simple – just use SelectedValue() to pull the numbers from each slicer – and then add them together.
VAR QST1 =
VAR QST2 =
VAR QST3 =
QST1 + QST2 + QST3
Perhaps this would get a little obnoxious if we tried to make a 20 question quiz in Power BI – but for small examples like this – it works well.
Synced slicers + Bookmarks = Power BI Report Memory