Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

achakilam1022
Contributor

Column total incorrect in a table (QlikSense)

Hi all,

I'm calculating a few measures using the following formulas.

Total Sales = sum(aggr(price, id, buyer))

Total Cost= sum(aggr(cost, id))

Reported Profit Margin= (Total Sales- Total Cost)/Total Sales

Now, a few buyers have a "adjusted profit margin" value and rest have null. Using this field I'm calculating New Sales as:

New Sales= Total Sales / ((1+ Reported Profit Margin) * (1 + Adjusted Profit Margin)) =


if(IsNull(adjusted_profit_margin), sum(aggr(price, id, buyer)),

(sum(aggr(price, id, buyer))) /

((1 + if(sum(aggr(price, id, buyer))='0',0,(sum(aggr(price, id, buyer))-sum(aggr(cost, id)))/(sum(aggr(price, id, buyer))))) * (1 + adjusted_profit_margin)))


when I calculate the new sales measure, the individual New Sales values of the buyers are correct but the column total ( of New Sales)  is same as the Total Sales. I'm confused  about why this is happening.



I appreciate any help with this. Please let me know if I need to modify anything or if there is any better way to do this.


Thanks.


Tags (2)
1 Solution

Accepted Solutions

Re: Column total incorrect in a table (QlikSense)

Wrap you expression around with Sum(Aggr(Expression, Dimension/s)) which will fix your total....

2 Replies

Re: Column total incorrect in a table (QlikSense)

Wrap you expression around with Sum(Aggr(Expression, Dimension/s)) which will fix your total....

achakilam1022
Contributor

Re: Column total incorrect in a table (QlikSense)

Thanks, Sunny

Community Browser