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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
achakilam1022
Creator II
Creator II

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.


1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

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

View solution in original post

2 Replies
sunny_talwar
MVP
MVP

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

achakilam1022
Creator II
Creator II
Author

Thanks, Sunny