11 Replies Latest reply: Oct 18, 2011 11:02 AM by Stefan Wühl

# Product of all Percentage of all rows in a table-diagram

Hi,

I have a nice problem:

There is a table (diagram) containing a number of rows, a dimension and a percentage:

AccountPercentage
A50%
B30%
C60%

What I want to see, is the product of all percentages (50% x 30% x 60% -> 0.5 x 0.3 x 0.6 -> 0.09 -> 9%) as a column:

AccountPercentage
A9%
B9%
C9%

How can I achieve this?

Martin

• ###### Product of all Percentage of all rows in a table-diagram

You could try something like

=exp(sum(total log(Percentage)))

And maybe you want to vote for http://community.qlik.com/ideas/1105

Regards,

Stefan

• ###### Product of all Percentage of all rows in a table-diagram

Hi Stefan,

thanks, but this only gives me 100% for all rows...

And i voted.

Martin

• ###### Re: Product of all Percentage of all rows in a table-diagram

See attached for a sample.

How do you calculate your percentage?

Stefan

• ###### Re: Product of all Percentage of all rows in a table-diagram

Hi,

my percentage is something like "sum(CounterM)  / sum(VK_MENGE)"

Thanks,

Martin

• ###### Product of all Percentage of all rows in a table-diagram

Then try something like

exp(sum(total aggr(log(sum(CounterM) / sum(VK_MENGE)),Account)))

• ###### Re: Product of all Percentage of all rows in a table-diagram

Hmm... like that I get only 0% everywhere... and when I use another expression with "sum(CounterM) / sum(VK_MENGE)" as xxx and use the result of this in the main formula "exp(sum(total aggr(log(xxx),Account)))", I get a 100% everywhere... can you see my mistake?

• ###### Re: Product of all Percentage of all rows in a table-diagram

Could you upload a simplified version of your app here in the forum? Or just some LOAD INLINE tables as text?

• ###### Re: Product of all Percentage of all rows in a table-diagram

Here we go. :-)

• ###### Re: Product of all Percentage of all rows in a table-diagram

I think something like

exp(sum(total aggr( log( Expression3/Expression1),TransID)))

in fact does work also in your example. It's just that your numbers are getting pretty small (note that we use a Product function here...).

You also have sometime multiple records per TransID, so you might want to use an aggregation on the percentage, maybe

exp(sum(total aggr( log( sum(Expression3)/sum(Expression1)),TransID)))

or

exp(sum(total aggr( log( sum(Expression3/Expression1)),TransID)))

depending what you want to achieve.

• ###### Re: Product of all Percentage of all rows in a table-diagram

Some more examples.

Stefan

• ###### Re: Product of all Percentage of all rows in a table-diagram

If I would get the product of all percentages as a total row it would also be ok:

AccountPercentage
A

50%

B30%
C60%
Total9%

Thanks,

Martin