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: 
furope
Contributor II
Contributor II

Average not considering selection of period

I would like to get the average of the stock for the selected period of time.

The expression I use is: sum(Stock)/count(MM) see file attached

in the example (F)emale has a stock of 1 in Apr 2019 and (M)ale a stock of 1 in May 2019. Now selecting both month I expect a value of 0.5 for both and not 1 for the average stock.

I hope someone understands my problem and can help me.

1 Solution

Accepted Solutions
furope
Contributor II
Contributor II
Author

a possible solution could be the following:

Sum(Stock)/(Count(TOTAL DISTINCT {1} MM)*Count(TOTAL DISTINCT {1} JJ))

so I get always the average of the selected period.

 

 

 

View solution in original post

5 Replies
Claudiu_Anghelescu
Specialist
Specialist

sum(Stock)/count(Total MM)

To help community find solutions, please don't forget to mark as correct.
furope
Contributor II
Contributor II
Author

This shows the right value of 0.5, but when i select M I still get a stock of 1 ?????

 

Claudiu_Anghelescu
Specialist
Specialist

I think that its correct 1 because there is only 1 month for each Gender, M and F.

To help community find solutions, please don't forget to mark as correct.
furope
Contributor II
Contributor II
Author

Well, for me it is not ok. When I select Apr and May so I expect the average of these two month. And when M has a stock of 1 in May and and no stock in Apr, so for me the correct average should be 0.5 and not 1 for the period of these two months.

Is there no simple solution for these problem?

furope
Contributor II
Contributor II
Author

a possible solution could be the following:

Sum(Stock)/(Count(TOTAL DISTINCT {1} MM)*Count(TOTAL DISTINCT {1} JJ))

so I get always the average of the selected period.