Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to show total value (of expression) as real total of elements

Dear All,

In excel, I make the report like below (or refer tab "report" in excel file), by:

- FCT & ACT: statistical data

- ERR = ABS(ACT-FCT)

- BIAS = ERR/ACT

In qlikview, the total of ERR & BIAS are not same as in excel (refer the highlighted value in RED and qlikview file).

So, question is How to show total of ERR as in Excel?

BUBrandProductFCTACTERRBIAS
BU 1Brand XProduct A1005050100%
BU 1Brand XProduct B100802025%
BU 1Brand XProduct C1001202017%
BU 1Total3002509036%
BU 1Brand YProduct E100703043%
BU 1Brand YProduct F1001151513%
BU 1Brand YProduct G1001202017%
BU 1Total3003056521%
Total 60055515528%
BU 2Brand AProduct H100110109%
BU 2Brand AProduct I100901011%
BU 2Brand AProduct J100802025%
BU 2Total3002804014%
BU 2Brand BProduct K1003070233%
BU 2Brand BProduct L1001404029%
BU 2Brand BProduct M1002080400%
BU 2Total300190190100%
BU 2Brand CProduct N1005050100%
BU 2Brand CProduct O10010000%
BU 2Brand CProduct P100110109%
BU 2Total3002606023%
Total 90073029040%
Total 1500128544535%
1 Solution

Accepted Solutions
marcus_sommer

You need to calculate your ERR on row-level and then aggregate them again. You could do it with:

sum(aggr(fabs(sum({<Type={"FCT"}>} Qty)-sum({<Type={"ACT"}>} Qty)), Product))

- Marcus

View solution in original post

6 Replies
marcus_sommer

You need to calculate your ERR on row-level and then aggregate them again. You could do it with:

sum(aggr(fabs(sum({<Type={"FCT"}>} Qty)-sum({<Type={"ACT"}>} Qty)), Product))

- Marcus

sunny_talwar

marcus_sommer‌ - Correct me if I am wrong, but wouldn't it be better to add all dimensions in the Aggr() function:

Sum(Aggr(fabs(Sum({<Type={"FCT"}>} Qty)-Sum({<Type={"ACT"}>} Qty)), BU, Brand, Product))

My fear is that the result might be incorrect if Product A is available under both BU 1 and BU 2. What do you think, is my concern valid?

Not applicable
Author

Both formulas work well. So, could you please explain why there is no different when we add in BU & Brand?

@Sunny, understand your concern. However, in my case, 1 product is belong to only 1 Brand, and 1 Brand is also belong to only 1 BU. The mapping is 1-1 all the time.

marcus_sommer

Hi Sunny,

many thanks for these hint and of course you are right, that all needed dimensions must be included within the aggr-statement. It's rather a lazy habbit from me to use only the most granular dimension for it - and in my main use-cases for the aggr the relation between these dimensions (like article, store or a date) and their prior dimensions are unique - but the most important point (by each expression) is to check if the results are like expected or not.

- Marcus

sunny_talwar

Dong Nguyen wrote:

However, in my case, 1 product is belong to only 1 Brand, and 1 Brand is also belong to only 1 BU. The mapping is 1-1 all the time.

If this is always true, then its safe to use Marcus's expression. I would request you to mark his response as the correct answer since he responded to your request first. My post was more of a caution to make sure that you don't fall into a trap where the relation is not 1-1. I have been there many times and that's why wanted to caution you.

Not applicable
Author

Thanks both of you