Data Models
Overview
Section titled βOverviewβModels, a powerful feature in Sprinkle that helps in presenting a multi-dimensional view of the table. It can be created without writing a single line of SQL query. It is configured with a simple point and :mouse_three_button:click user interface.
Watch Video :tv:
Section titled βWatch Video :tv:βPrimarily Models comprise date dimensions, dimensions, and measures.
The Model page consists of 5 tabs, namely, Table, Column, Expression, Joins, Hierarchies
The table tab contains an overview of the model, the name of the schema and the table on which the user wants to create a model. For creating a model, a table has to be selected and its columns need to be mapped to the Measures and Dimensions fields.
Columns
Section titled βColumnsβIn the column tab, the list of columns of a given table is catalogued. Here, the user selects dimensions, and measures at different aggregates like sum, average, count, distinct count, etc whereas, in date dimensions, the time frame can be set for yearly, quarterly, monthly, weekly, daily and hourly basis.
Expressions
Section titled βExpressionsβSprinkle allows users to create calculated columns at the model level. These calculated columns might be a dimension expression or measure expression on a given table. The tool also supports dynamic bucketing where users can give just the ranges and variable names and the buckets are created easily.
Joins is a feature that allows the user to join the fact table (from which the model is created) with other models. All the dimensions present in the joined Model can be used in this model. For example, an Order Model having customerId as one of the columns can be joined to the Customer table. Similarly, it can also be joined to the Product table.
Hierarchies
Section titled βHierarchiesβHierarchies can be added to define a relation between fields, where values of one can be controlled by other in a nested way.
For eg, Country -> State -> city This can be a hierarchy where city value is dependent on state, state value is dependent on country.
Hierarchies then allow you to use the drill feature on Reports & Dashboards allowing you to drill down and drill up on your data to perform interactive analysis, explore trends. (Read more about hierarchies here)
Feature Walkthrough :person_walking:
Section titled βFeature Walkthrough :person_walking:β1. Creating a Model
Section titled β1. Creating a ModelβTo create a model :mouse_three_button:click on New. Give a name & description to the model and select the SQL Transform table or the DB ingested table and :mouse_three_button:click on Next.
.gif)
Create a Model
2. Columns
Section titled β2. ColumnsβAfter creating the model all the attributes present in the SQL Transform table are listed. Sprinkle by default chooses the dimensions, measures and date dimensions. The user can choose dimensions by just clicking on the checkbox.
.gif)
The measure can be chosen by selecting the required aggregate function like distinct, Average, Sum and Count.
In the below:arrow_down: case, the count is selected for the Client column.
.gif)
Measures
Date dimensions are the time span on which a report is built.
Sprinkle supports hourly, daily, weekly, monthly, quarterly and yearly reports.
The below screenshot shows the date dimensions for the order date column.
Then click on the βCreateβ button to create the model.
.gif)
Date Dimensions
Now you can Click on βCreate Reportβ, to create a Report directly from the model page.
.gif)
Creating a report
3. Expressions
Section titled β3. ExpressionsβThe user can also add customized dimensions and measures on the Expression tab in models. Calculated columns are created using expressions to obtain the desired answer, in this case, the total sum of the line amount is created.
:mouse_three_button:Click on Validate to test the expression, before saving it. Click on Done to save it as a customised dimension or measure.
You can also use variables in your expressions. Learn more about Variables here.
.gif)
Expressions: Validate & Done
4. Joins
Section titled β4. JoinsβJoins is a feature that allows the user to join the fact table (from which the model is created) with other models. All the dimensions present in the joined Model can be used in this model.
For example, a Google Ads Model having City as one of the columns can be joined to the Sales fact table as shown in the example below.
In Model joins, the Joins type can be selected from a list, say, Left Outer, Right Outer, Inner, or Full Outer Join. In addition to that, multiple conditions can also be created at one instance to join two models
.gif)
Creating Joins
5. Hierarchies
Section titled β5. HierarchiesβBrowse to the Hierarchies Tab to Add details about the Hierarchies.
Here the Hierarchy levels need to be defined in the right sequence and saved in the model, and model build jobs need to be run successfully at least once so that they can be used in the dashboard.
Read more about hierarchies here.
6. Row-level Security
Section titled β6. Row-level SecurityβRow-level security lets you manage the row-level access of the models. It lets you restrict usersβ access only to the relevant part of the table. For example, you can restrict users in βKarnatakaβ to access the sales data only relevant to βKarnatakaβ from the sales table.
Refer to this document for steps to create and use row-level security.
7. Column Masks
Section titled β7. Column MasksβIn a Model, a set of fields can be dynamically masked for a group of users using the βColumn Masksβ feature. Data in these fields are not visible when the restricted user accesses Reports or Dashboards.