Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
MattSmart
Employee
Employee

An overview on how to text and use expressions with Master Items.

As a new-er member of Qlik’s demo team, I am often learning new approaches to building expressions and visualizations when creating apps. Currently I am working on a college football app that uses a variety of expressions to process the data we’ve loaded. Here I will explain some of the techniques that I have used to troubleshoot my expressions.

In our college football app, we’re bringing in a lot of data from a lot of different places, matching them up, adding them, multiplying, dividing, all manner of things to get the information we need. The primary goal of this app is to find ‘The Greatest College Football Team’. The ‘greatness’ of each team was determined by a combination of factors that combined into ‘Total Points’, the team with the highest amount of points, would be crowned the greatest.

To find these ‘Total Points’, we have a formula:

MattSmart_0-1703280923071.png

 



That’s not the longest expression that you will find, you might have created some longer ones yourself, but what are these pieces to this expression? Each portion of this expression is created by a combination of data that we’ve loaded into our app, let’s look at one of them:

MattSmart_1-1703280923072.png

 



Now we’ll get into creating and testing our expression. First, we’ll select a team we’ll be finding the values for, with this example we’ll use 2019 LSU. To ensure that I have the right measures, I create a new sheet in my app, then KPIs for each value in my expression; Total Offensive Yards Per Game, Points Per Game and Offensive Turnovers. This is to ensure I am working with the correct values. Additionally, I add a filter pane to my sheet to select my team.

My Sheet now looks like this:

 

MattSmart_2-1703280923085.png

 

We’ll now double check our values against our source data, and we have a match. Now let’s combine these values into an expression. Add another KPI to sheet, click Add, then the fx to being creating your expression. We’ll now arrive at our expression editor. I often find it helpful to open a second window of your app so you can reference back to KPIs to ensure you’re collecting the correct values.

MattSmart_3-1703280923106.png

 

Now we’ll add our values into the expression in the form of our original equation.

MattSmart_4-1703280923108.png

 

You may notice that these values are in different colors. The light blue/grey colors are master measures, where as the gold are fields directly from our data set. Make sure to include your parenthesis to control the order of operations in the equation. For our example, we want Total Yards and Points Per Game to be added together before being divided by Offense Total Turnovers, so we’ll put parenthesis around them.

Before selecting apply, ensure that Qlik OK’s your equation, this information can be found at the bottom of the expression editor.

Some of the best advice I can offer when troubleshooting an expression is to make sure you have an even number of parenthesis.

MattSmart_5-1703280923111.png

 

Here we have an extra parenthesis, and it is causing us to return an error in our expression. If we remove it, we’ll see that Qlik gives us the OK.

MattSmart_6-1703280923114.png

 

Now we’ll click apply and check the value we returned.

Our sheet should now look like this:

MattSmart_7-1703280923127.png

 

Looking back at our reference data, we’ll see that our expression is working as it should. Venturing back into ‘Edit Sheet’ we can click on the KPI for our expression and open up the measure to find this screen:

MattSmart_8-1703280923130.png

 

At the bottom, we’ll find ‘Master item’ and a button that says ‘Add new’. Click on that to open this menu:

MattSmart_9-1703280923137.png

 

We can now add a name to our expression and click create, turning our expression into a measure that we can use throughout our app.

Now we can do this for all of the sections of our Total Points expression, using the same technique to create the Defense Percentile, Special Teams Efficiency and S.O.S. Percentile, each of these becoming their own measures whose expressions will be below. Our sheet should again have the individual parts of our expression so we can double check the values.

Defense Percentile:

MattSmart_10-1703280923138.png

 

Special Teams Efficiency:

MattSmart_11-1703280923139.png

 

S.O.S. Percentile:

MattSmart_12-1703280923140.png

 

MattSmart_13-1703280923152.png

 

Our new expression will look like this:

MattSmart_14-1703280923153.png

 



Let’s start building. We’ll start with the three measures at the beginning.

MattSmart_15-1703280923154.png

 

Remember to add your parenthesis to group these measures and then refer back to your KPI to check that our values are correct.

MattSmart_16-1703280923156.png

 

Perfect! Now we can begin adding onto it. Until our expression is fully filled out.

MattSmart_17-1703280923158.png

 

 

Then we double-check our values, and then we can make this a measure as well!

MattSmart_18-1703280923161.png

 

Great! Now let’s look at our work, what have we accomplished. Through this process we have taken what would have been this equation:

MattSmart_19-1703280923163.png

 

 

Into:

 

MattSmart_20-1703280923163.png

 

 

A bit easier to work with. And we have checked our values along the way to ensure they are correct. With this, we can use this one small, easy to use measure all over our app without having to worry about a missed parenthesis, or an incorrect value.