Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
March 26 at 10am ET: See how Qlik drives growth and value in ISV segment - REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
sifatnabil
Specialist
Specialist

3 month average not working in straight table

Hi all,

I have a straight table with dimension = CLIENT and in the expression, I'm using set analysis to get the revenue vs. 3 month average as a percentage, which is (revenue - 3m avg)/3m avg, like below:

(sum({<[Year]={'$(=max([Year]))'},[Month]={'$(=$(vCurrentMonth))'}>} [REVENUE])

-

(sum({<[Year]={'$(=max([Year]))'},[DATE]={'>=$(=monthstart(max([DATE]),-2))<=$(=monthend(max([DATE])))'}>} [REVENUE])/3))

/

(sum({<[Year]={'$(=max([Year]))'},[DATE]={'>=$(=monthstart(max([DATE]),-2))<=$(=monthend(max([DATE])))'}>} [REVENUE])/3)

But for some reason this expression ignores the dimension and gives the 3m average of ALL clients on each row. What could be wrong with this?

5 Replies
sifatnabil
Specialist
Specialist
Author

bump

HirisH_V7
Master
Master

Hi ,

May be like this,

=(sum({<[Year]={'$(=max([Year]))'},[Month]={'$(=$(vCurrentMonth))'}>} [REVENUE])

-

(Avg({<[Year]={'$(=max([Year]))'},[DATE]={'>=$(=monthstart(max([DATE]),-2))<=$(=monthend(max([DATE])))'}>} [REVENUE])))

/

(Avg({<[Year]={'$(=max([Year]))'},[DATE]={'>=$(=monthstart(max([DATE]),-2))<=$(=monthend(max([DATE])))'}>} [REVENUE]))

Use this expression,

-Hirish

HirisH
“Aspire to Inspire before we Expire!”
sunny_talwar

Can you may be try breaking the expression into pieces and build it together one by one. Start with a simple expression Sum(REVENUE) against the dimension Client to check if that is working or not. If you still get same number for all rows, I would think that somehow Client and Revenue fields are not linked to each other. but if they do, I will check this -> sum({<[Year]={'$(=max([Year]))'},[Month]={'$(=$(vCurrentMonth))'}>} [REVENUE]) and this -> sum({<[Year]={'$(=max([Year]))'},[DATE]={'>=$(=monthstart(max([DATE]),-2))<=$(=monthend(max([DATE])))'}>} [REVENUE])/3) as two separate expressions. and go on from there.

jonathandienst
Partner - Champion III
Partner - Champion III

I suggest that you upload your qvw or a representative sample. It looks like the problem could be that the CLIENT and REVENUE are not associated correctly.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
sifatnabil
Specialist
Specialist
Author

Sorry guys, the issue was this: [Year]={'$(=max([Year]))'}, since it's January 2016, it's not able to look back 3 months because of this restriction, hence it didn't work. Removing this worked. I'm not sure why it caused the expression to aggregate over all clients though.

Also, the client and revenue are on the same table so there aren't any issues with that.