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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
c_latham
Contributor III
Contributor III

Average Monthly Aggregate

Hi All,

I have a real basic QV App whereby I have a dimension table of Stock control, like below:

KeyLocationDateInDateOut
110101-01-2018 01:0002-01-2018 01:00
210101-02-2018 06:5520-02-2018 05:00
310202-01-2018 00:0003-01-2018 00:00
410313-03-2018 06:0015-03-2018 07:00
510102-02-2018 23:0028-02-2018 23:00

Then a Fact table:

KeyDwell Days
11
219
31
42
526

I then have a MasterCal based on DateIn.

What I expect using this expression is to get an average dwell per month =Aggr(Avg([Dwell]),[MonthYear])

With my expected results being:

MonthYearAvgDwell
Jan 20181
Feb 201822.5
Mar 20182

What I am getting however is the same result per month:

MonthYearAvgDwell
Jan 20189.8
Feb 20189.8
Mar 20189.8

Can someone point me in the right direction?!

Thanks

16 Replies
sunny_talwar

Would you be able to share your script?

sunny_talwar

I guess the problem is that you don't have your master calendar connected to your fact table

Capture.PNG

Since MonthYear is not connected to the main table....Avg([Dwell in Location]) is same across MonthYear... In the file that you provided what is DateIn and what is DateOut? Is t_put - DateIn and Next Location Put - DateOut?

Also, what if DateIn and and DateOut span multiple months? Is that something which can happen?

c_latham
Contributor III
Contributor III
Author

Not entirely certain I know how I would get the Master Cal to link to the Fact table. If I did a date(t_put), MM-YYYY on the fact table I would get a link?

Again you’re correct on your assumption of t_put and Next Location Put!

Yes that’s true stock can come in and stay in a location for months and not move, again not entirely certain I would know how to get this to display! Thanks Sunny!

sunny_talwar

Did you look at the thread I shared earlier?

IntervalMatch

I would suggest you to go through the thread and see if this is sort of what you are looking to do?

c_latham
Contributor III
Contributor III
Author

Thats exactly what I need (And thought I had done!). I got my wires crossed! It’s been a good few years since I last used QV! Now I’ve got to the position I’m in, I think next steps are interval match and then bring the master calendar into the fact table! Do you agree?

sunny_talwar

I would keep them separate because bringing them together can cause an explosion of data... you wouldn't want that.. there will be a synthetic key... but that synthetic key is actually not bad....

c_latham
Contributor III
Contributor III
Author

‌You mean on the master calendar part?