Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to create a new measure

Hi, I'm very new to Qlik Sense and need to know how to create a new measure from existing measures.  For example, I need to calculate gross margin based on sales and cost.  I've watched many videos but have not found this specific action. 

3 Replies
Josh_Good
Employee
Employee

Hi Teresa,

It is not possible to use a measure to create a new measure.  However, what you can do is use variables.  https://help.qlik.com/en-US/sense/3.1/Subsystems/Hub/Content/Variables/use-variables-expression.htm

So for example, you could create a variable that you could call 'vSales' which would be defined as Sum(Sales) and a variable called 'vCost' which could be defined as Sum([Costs of Goods])

Then you can create a new variable that you could call vMargin and define it as

($(vSales) - $(vCost)) / $(vSales)


Note the "$" is used to tell Qlik to evaluate the variable in the brackets and return the result.


Josh

-Qlik

Not applicable
Author

Thank you Josh, I was able to create the variables, but now how do I use them in a visualization?  It seems that I can only select dimensions and measures. 

dezrrehm
Contributor II
Contributor II

Create a new measure by clicking "Create new" in your master items.

The expression for your measure is just the following:

$(MyVariableName)

Give the measure a name, and optionally a description or tags, and click Create.

That's all there is to it.

There are some technicalities if you are looking to represent varying aggregation levels, or if you are using variables for Labels or in If statements - but most of the time it's pretty simple.