Discussion Board for collaboration related to QlikView App Development.
Hello!
I have table with dimensions
Factory,ItemGroup,Item
I want to add expression to count number of months with sales more than average in month
For example item1, Sales June = 10, July = 12, August=11, September = 13
average = 11,5, the expression should give 2 (because 2 months have sales more than 11,5)
I try to write such formula, but it gives null
Sum
(
if
(
aggr(Sum({<Customer={'Outer'}, SalesDate={">=$(vDateForABC)"}, Qty={">0"}>} Qty),Year,Month,Factory,ItemGroup,Item)
>=
avg(aggr(Sum({<Customer={'Outer'}, SalesDate={">=$(vDateForABC)"}, Qty={">0"}>} Qty),Year,Month,Factory,ItemGroup,Item))
,1,0
)
)
What could be the mistake?
Hi Alex,
Check whether the variable is getting set properly.
Can you please provide the sample data.
Ok, without variables. the same result
Sum
(
if
(
aggr(Sum(Qty),Year,Month,Factory,ItemGroup,Item)
>=
avg(aggr(Sum(Qty),Year,Month,Factory,ItemGroup,Item))
,1,0
)
)
Can you please post your app, let me have a check
Application contains cyrillic
Not able to open the attached qvw
Hi,
I am not able to open the document, can u upload it again.
try this
Hi,
First check that below expression text object, then check in chart
avg(aggr(Sum({<Customer={'Outer'}, SalesDate={">=$(vDateForABC)"}, Qty={">0"}>} Qty),Year,Month,Factory,ItemGroup,Item))
expression gives you correct avg
if not then use Total Keyword like
avg(aggr(Sum({<Customer={'Outer'}, SalesDate={">=$(vDateForABC)"}, Qty={">0"}>} Total Qty), Year,Month,Factory,ItemGroup,Item))
Regards
thanks, but i resolved my problem, First of all it is not correct to use nested aggregation as i used before. And yes, total is necessary