Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
ziabobaz
Not applicable

sum of Rows in a table

Hi!

I have a table

Column(1) = class(sales, 500)

Coulmn(2) = count (distinct Brand) / count (distinct total Brand)

Screenshot_61.jpg


The problem is that the column(2) does not sum up to 100%. I know the reason - some of my Brands have zero on negative Sales, or just don't have names (accounting software bug). I solved this by "Not showing zero values" in the Dimension in table properties, but I need to do something with Column(2) in order not to count those values as well.


The easiest way is to calculate Sum of Rows of the Column (1) and redo the formula:

Column(2) = Column (1) / [sum of rows of column (1)]


Is the way to achieve this? In fact i need a reference to a total (50 in my example).


Thank you

1 Solution

Accepted Solutions
sunny_talwar
Not applicable

Re: sum of Rows in a table

What if you do this

Count(DISTINCT [Brands])/Count(TOTAL DISTINCT Aggr(If(Sum(InventoryBalance)/Sum(Sales) > 0, [Brands]), Brands))

11 Replies
sunny_talwar
Not applicable

Re: sum of Rows in a table

What is your expression for Column(1)?

ziabobaz
Not applicable

Re: sum of Rows in a table

i will try to simplify it, because the original formula is a monster with set analysis:

class(

aggr(

if(

Sum(Sales)

=0,

'10000',

Sum(InventoryBalance)/Sum(Sales))

, [Brands]),   

    500)

sunny_talwar
Not applicable

Re: sum of Rows in a table

I was talking about the expression for this guy here

Capture.PNG

ziabobaz
Not applicable

Re: sum of Rows in a table

Sorry

count( DISTINCT [Brands])

sunny_talwar
Not applicable

Re: sum of Rows in a table

So this isn't working?

Count(DISTINCT [Brands])/Count(TOTAL DISTINCT [Brands])

ziabobaz
Not applicable

Re: sum of Rows in a table

it shows more values than I need, because it includes Brands that have sum(InventoryBalance) / sum(Sales) <=0.

I excluded those values in the table properties (unchecked  "show zero values''), so the GUY row shows me 50 and the next column shows me 54.

sunny_talwar
Not applicable

Re: sum of Rows in a table

What if you do this

Count(DISTINCT [Brands])/Count(TOTAL DISTINCT Aggr(If(Sum(InventoryBalance)/Sum(Sales) > 0, [Brands]), Brands))

shadow99
Not applicable

Re: sum of Rows in a table

Did you check for the round off?The totals mismatch sometimes when they are rounded off..

ziabobaz
Not applicable

Re: sum of Rows in a table

Yeeeeeeeees!