Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
vikas_nandanwar
Creator II
Creator II

Average - Department level Sum

Hi,

My data is as below -

 

DateDeptTotal
1-JanA100
1-JanB90
1-JanC 500
2-JanA110
2-JanB70
2-JanC 480
3-JanA150
3-JanB50
3-JanC 580
4-JanA120
4-JanB60
4-JanC 510
5-JanA180
5-JanB50
5-JanC 550

Pivot -

  

Row LabelsSum of Total
1-Jan690
2-Jan660
3-Jan780
4-Jan690
5-Jan780
Grand Total

3600

I want Average of Total of Date in Grand Total

Answer = 720

please help

23 Replies
Anil_Babu_Samineni

First try to place first and second as inversion like

=Avg( Aggr( Sum(Total), Date, Dept))

Read more Aggr - chart function ‒ QlikView

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
vikas_nandanwar
Creator II
Creator II
Author

This doesn't work too
I had to pivot my full data and aggregate the dept, and then use the  =Avg( Aggr( Sum(Total), Date)) expression works with desired results.


Anil_Babu_Samineni

So, Does you added Dept field to your field distribution. If so, It should work or else try this with only Date field as dimension

=Avg( Aggr( Sum(TOTAL <Dept> Total), Date))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
vikas_nandanwar
Creator II
Creator II
Author

Thanks this worked

swuehl
MVP
MVP

Not really sure what you mean with saying my expression does not work with multiple records per Date.

This is what I get with your updated sample data and my suggested expression:

Date Avg( Aggr( Sum(Total), Date))
1-Jan720
2-Jan690
3-Jan840
4-Jan720
5-Jan810
Total 756

Isn't 756 what you expect to get?

Maybe you missed the inner aggregation function, Sum(Total)?

vikas_nandanwar
Creator II
Creator II
Author

The above expression worked to some extent.

Now When i am drilling down to the final date, Its not giving me the correct answer.

My data includes -

    

DateDeptWorkCenterSub DeptQtyCo. CodeType
2-Jan-17MfgAPURE10ZZGold
2-Jan-17RMBKARAT30XXPlatinum
2-Jan-17MfgCPURE30YYSilver
2-Jan-17JWASPRUE20ZZPlatinum
2-Jan-17MfgDFIL40XXGold
2-Jan-17RMDBAG50YYSilver
3-Jan-17MfgACHK10WWPlatinum
3-Jan-17JWBFIL20VVGold
3-Jan-17MfgCFILWIP20WWGold
3-Jan-17JWBCHK10VVSilver
3-Jan-17RMCFIL30XXPlatinum
3-Jan-17RMBBAG30ZZPlatinum
3-Jan-17MfgACHK20YYSilver
4-Jan-17JWBFIL50VVGold
4-Jan-17MfgCFILWIP10WWGold
4-Jan-17RMBBAG20VVSilver
4-Jan-17MfgCFIL40XXPlatinum
4-Jan-17JWAAAG40ZZSilver
4-Jan-17MfgDFIL20WWGold
4-Jan-17RMAAAG10YY

Platinum

I need to check drill down on a single date say 2nd Jan = Total Inventory of Qty = 180

with above expression

vikas_nandanwar
Creator II
Creator II
Author

Any suggestions?

swuehl
MVP
MVP

What do you get with my expression and what do you expect to see.

vikas_nandanwar
Creator II
Creator II
Author

Hi,

I am giving you proper answer.
My final aim is-

1.     To get average inventory department wise whenever I am at multiple dates or at clubbed Month Level Avg(Aggr(Sum())) gives me this

2.     When I select a single date from filter, I should get total for that date

Vikas

swuehl
MVP
MVP

What is the expression context? Which dimensions are you using and are you using dimension groups or multiple dimensions? Collapsed dimensions in a pivot table?

Some screenshots may help to see what your exact issue is.