Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculation in line chart not totaling up correctly

I have 5 different charts with different calculations that when I am just looking at 1 customer the number is correct but when I look at total company it is not correct.  I will give 1 chart as 1 example.

In one of the charts I am trying to calculate the seatbelt exceptions.

So in the line chart it is by date for the dimensions and for the expression I first tried this calculation and I was not getting any of the correct  calculations for 1 customer on one date or correct calculations for total company.

the calculation should give me (if I could get it correct) on date 6/5/2017  1 customer (customer number 2) 3663 and for total company on that date it should give me 9963.

Try 1:

round(Sum({<FileDate = >}([Total Distance Miles] / Seatbelt)))

This gave me 1 customer = 896 and total company = 22088

Try2:

Next I have tried doing the calculation in the script.

So something like this:

LOAD

if((S10 + HB + SB + HA)=0,0,

round(TDM / SB) as SeatBeltS;

LOAD

Sum ([Total Distance Miles]) as TDM,

Sum (Seatbelt) as SB

Resident Scorecard;

and then I did this for the expression

Sum({<FileDate = >}(SeatBeltS))

This gave me for 1 customer = 3663  (which is correct) but for total company = 58494 (which is wrong)

I do not know what I need to do to get the total company to show the correct number? 

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I figured out what I need to do.  For anyone in the future who might need this answer I had to sum up each by themselves.

round(sum({<FileDate = >}[Total Distance Miles]) / sum({<FileDate = >}Seatbelt))

View solution in original post

1 Reply
Anonymous
Not applicable
Author

I figured out what I need to do.  For anyone in the future who might need this answer I had to sum up each by themselves.

round(sum({<FileDate = >}[Total Distance Miles]) / sum({<FileDate = >}Seatbelt))