Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating column percentage

Hi, I need to calculate a percentage in a column:

     Column(1) / Sum(Total <Id> Sales),

but the percentage has an error, because instead to use 34700, the value use it's 29629 (=34700 - 1538 - 3533), 1538 and 3533 are repeat (colour red and blue). but, I don't know. why happened with it?  Thank you.

IdSales

% Correct

using 34700

% Wrong

using 29629

Mark115384,43%5,19%
Mark1517714,92%17,47%
Mark125777,43%8,70%
Mark1353310,18%11,92%
Mark12100,61%0,71%
Mark1389411,22%13,14%
Mark11300,37%0,44%
Mark11720,50%0,58%
Mark115384,43%5,19%
Mark1353310,18%11,92%
Mark1920026,51%31,05%
Mark131989,22%10,79%
Sum OK34700
Sum Wrong29629
2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

If this is a straight table, select sum of rows for the % expression.

If this is a pivot: Use this aggr expression to get the total of the percentages (as opose

Sum(Aggr(Sales / Sum(Total <Id> Sales), Id, <other dimensions>))

<other dimensions must include all the table dimensions - so if Date and Customer are other dimensions:

Sum(Aggr(Sales / Sum(Total <Id> Sales), Id, Date, Customer))

That will give you the sum of the %ages.

HTH

Jonathan

PS I am assuming that the expression for Column(1) is Sum(Sales)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
MK_QSL
MVP
MVP

Check enclosed file...