Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Action-Packed Learning Awaits! QlikWorld 2023. April 17 - 20 in Las Vegas: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count number of months with sales more than average

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?

9 Replies
avinashelite

Hi Alex,

Check whether the variable is getting set properly.

Can you please provide the sample data.

Not applicable
Author

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

  )

)

avinashelite

Can you please post your app, let me have a check

Not applicable
Author

Application contains cyrillic

anbu1984
Master III
Master III

Not able to open the attached qvw

avinashelite

Hi,

I am not able to open the document, can u upload it again.

Not applicable
Author

try this

PrashantSangle

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

Great dreamer's dreams never fulfilled, they are always transcended.
Not applicable
Author

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