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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expressions(sum) results is not consistent in my bar chart.

As you can see in my first screenshot here:barchart1.JPG.jpg

The value 1,139 is not consistent when I click the bar because it gives me this:

barchart2.JPG.jpg

The value now is 245. I don't understand why it changes. The correct value should be 245 but I don't know where it gets 1139.

I have a table with lists of companies and I am segregating it by number of employees. The value in the bar chart is the sum of all cars within that company range(in this case 50-99 employees).

I will attach my Qlikview document so you can understand what I mean. Please someone help me. Thanks a lot.

2 Replies
MK_QSL
MVP
MVP

Change your expression to

SUM(Distinct quantity)

or

sum(aggr(sum(DISTINCT quantity),$(=GetCurrentField(ComparisonDim))))

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Reagan,

the issue here is with your data - looking at it I see that each value of id (your key field?) has multiple records as it relates to more than one value of quantity_types, flt_type_id, and type_of_cars (attributes of the car_brands?).

I'd suggest splitting these fields out to a separate table. Here's a script to do so.

LOAD flt_brand_id,

   
car_brands,

   
created_at,

   
updated_at,

   
id,

   
quantity,

   
yes_no,

   
flt_company_id,

   
timestamp,

   
flt_fuel_card_id,

   
flt_insurance_id,

   
flt_finance_type_id,

   
tendency,

   
cycle,

   
sup_company_id,

   
last_purchase,

   
flt_leasing_supplier_id,

   
next_purchase,

   
finance_type,

   
fuel_cards,

   
insurances,

   
leasing_supplier,

   
last_name,

   
first_name,

   
flt_person_role_id,

   
gender,

   
phone_number,

   
email_address,

   
title,

   
//quantity_types,

    //flt_type_id,

    //type_of_cars,

    company_name,

   
uid,

   
address_line1,

   
address_line2,

   
postal_code,

   
location,

   
fax_number,

   
home_page,

   
branch_code,

   
no_of_employees,

   
IF ( [no_of_employees] >= 250 , '>= 250 Employees',

 
IF ( [no_of_employees] >= 100 and [no_of_employees] <= 249, '100 - 249 Employees ',

 
IF ( [no_of_employees] >= 50 and [no_of_employees] <= 99, '50 - 99 Employees',

 
IF ( [no_of_employees] >= 20 and [no_of_employees] <= 49, '20 - 49 Employees',

 
IF ( [no_of_employees] >= 10 and [no_of_employees] <= 19, '10 - 19 Employees',

 
IF ( [no_of_employees] >= 4 and [no_of_employees] <= 9, '4 - 9 Employees',

 
IF ( [no_of_employees] < 4, '< 4 Employees'

) ) ) ) ) ) ) 
as employee_range,

   
turnover,

   
legal_form,

   
year_established,

   
duns_parent_company,

   
designation2,

   
canton,

   
last_update,

   
user_id,

   
liquidated;

SQL SELECT *
FROM [Step_1].[Write QlikView 1];





Table2:

LOAD

   
car_brands,

   
quantity_types,

   
flt_type_id,

   
type_of_cars;

SQL SELECT *
FROM [Step_1].[Write QlikView 1];