Using the dataset I
This section uses the model created in the first and the second step of the dataset tutorial. If you did not do them you can do them first or use your own model with a dataset.
Next, we are going to let the user choose an employee he or she wants information on. We will do this by asking a question, making a selection on our dataset and presenting the result. While doing so you will learn the basics of dataset handling.
Asking a question
To start off, add a node ‘question’ after the node ‘done’. In this node we will ask our question. Your graph should look like this:
In this node question, add a question via
[Actions > Question] or any other method. Now, it is important that you tick the use dataset checkbox in the bottom left of the question screen. Next, select Drop-down list. This will present you with the following screen:
Next, enter a name for the question, enter a text for the question. Furthermore, select the right dataset in the top right. Now you should be able to select the right dataset under ‘variable to use’. For the field, you can select either the first or the last name of the employee. The resulting window should look like this:
That’s it! To check your question, simply save and run your model. If you’ve done everything right, you can now select an employee from your dataset as answer to the question:
Now you might wonder why we needed a dataset for this kind of question. After all, would it not have been easier to create a custom input type with the answer options? The answer is that both have their uses. If you only want to have these answer options, a custom input type would do the trick. However, as we will show next, you can use the selection of the user to present other dataset information.
Datasets and selections
Now that our user has chosen an employee, we want to present all data on that employee. This is made very easy with datasets! It works as follows: when we created our question, it made a new dataset for that question, on which the user made a selection. Therefore, our question ‘employee’ contains only information on the relevant employee! You can view this with the data inspector:
Now we can use a text field with variables in it to present this data to the user! You can add a node ‘result’ after the question node and add a text to it. In this text you can then put the contents of the question. If you forgot how to use variables in text fields, please take a look at the section Showing your formulas. The result might look like this:
Note that we have to use a lot of information to tell the studio what to use. First, we use main.question.employee to indicate the question we asked the user. However, this is a dataset with a node ‘data’ in it containing all our information. Therefore we need to add data.variable for each piece of text we want. You can also use the Finder to make things easier and just select your data. This will save quite some typing work:
In the next section, we’ll explain how to make your own selections on datasets with the