Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Expression Total not calculating

I have a straight table with 3 columns: Gross Revenue; COGS; and GP%.

The Total Mode for the first 2 columns is set to Sum, and is calculating the correct figures. The Total Mode for GP% is set to Expression Total, which is returning '-'.

Gross RevenueCOGSGP%
$405.00$139.3565.59%
$87.27$30.9664.53%
$3,545.82$1,531.5056.81%
$18.00$6.2765.17%
$13.64$4.7065.53%
$659.45$273.4358.54%
$4,729.18$1,986.21 -

The GP% expression is '= 1 - ([COGS] / [Gross Revenue])'. I am referencing the label names of the first 2 columns in this formula, could that be the reason it is not calculating?

3 Replies
jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hi,

I think the problem here is that your columns in the straight table are called exactly as your fields, so when you're doing the calculation in the GP% column, QlikView is taking the name of the fields instead of the columns. Because of this, the expression totals appears as null ( - ), because internally qlikview is taking your formula as "1 - (only([COGS])/ only([Gross Revenue]))".


. Try changing the name of the columns in the straight table. You can add a blank space after the last letter so the names will be different and then you can call the column names like this:

= 1 - ([COGS ] / [Gross Revenue ])'


Also as a tip you can differentiate an object column from a field looking at the color it has when typing the expression (columns are shown in blue, while field names are shown in dark red),


regards

Anonymous
Not applicable
Author

Jaime, thank you for your response. Unfortunately this is not the problem, as I do not have fields for COGS and Gross Revenue, they are calculated from the fields CostPerUnit * Qty and PricePerUnit * Qty.

I have tried moving all my formulas into variables but this results in the same problem. My next step will be to edit the script to create the fields COGS and Gross Revenue, calculating them during the load.

Anonymous
Not applicable
Author

I have found by calculating COGS and Gross Revenue in the load script, rather than in the straight table, the GP% total calculates.