Expertsystemen

 

Using the dataset II

This section uses the model created in the first, the second and third step of the dataset tutorial. If you did not do them you can do them first or use your own model with a dataset.

In this section we will make our own selection on our dataset based on age. After we’ve done this, we will show the result to the user in a table.

Making selections on your dataset

Before we start, please add a node ‘selection’ to the node ‘done’ and a node ‘result_2’ to the node ‘selection’. Make sure we go to the ‘selection’ node by moving the connection to that node up, or delete the ‘question’ and ‘result’ nodes. You can see the result in this screenshot:

The graph we're working on
The graph we’re working on

In the node ‘selection’ we first of all need the dataset we created. To do so, we’ll import it from the node we created it: ‘add_dataset’. Create a formula with ‘employee_data’ as type, give it a name and use the Finder to find the dataset:

Importing the dataset with the finder
Importing the dataset with the finder

Now we’ve got an exact copy of our dataset! We will use this copy to make our selection on. Our selection is going to be quite simple: everyone older than 40 will be selected, the rest will be discarded. To do this, we need one formula. If you forgot how formulas worked, please take a look at Getting started with formulas and/or Formulas.

Add a new formula to the node with the same name as our dataset and make sure it has the correct type (employee_data). Next, look up how the select() function works by navigating to [Functions > Datasets > Select()]. Now, use the select() function to select only those employees who are older than 40 years old. Below is shown how to do it:

Using the finder to create our formula
Using the finder to create our formula

That’s it! We’ve made a selection on our data. You can check how the dataset looks by using the inspector as shown in Inspecting datasets and see the difference before and after the selection. Note that if nothing happens either need to add some text to your node or you mixed up the order of the formulas (import first, then the selection).

Showing the selection

Now we will show the selection we made to the end user. To do this we will use a grid. A grid is a type of presentation that allows you to show a table to the user. You can also allow the user to enter or edit data in it, but for now we will just present something.

First, we need to import the dataset we made a selection on from the node ‘selection’. For this you can add a formula ds_employees := selection.ds_employees to the node ‘result_2’:

Import the dataset
Import the dataset

Next, add a question, check Use dataset and select Grid. Give the grid the name of the dataset (‘ds_employees’) and check Use column names. Last, you need to add the information to the grid itself. This is done by pressing the add icon under example (not the one next to the Type!) and entering the information. The result should look like this:

Setting up the grid
Setting up the grid

Don’t worry if you make a few mistakes, grids require some effort to get to work. Just make sure you follow all the steps and everything should work out. When you’re done you can run your model and test what happens. If everything works well you should get the following screen:

The resulting grid
The resulting grid

Don’t mind the rather simple layout of the grid. If you publish your models they’ll look a lot better and it’s possible to add your own styles. In the last section, we’ll do something slightly more complicated and use our own function to calculate the current age and show that to the user.