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: 
Anonymous
Not applicable

6 months rolling set analysis expression not working with aggr function

Hi,

avg(aggr(((Sum(a/b))*c),[emp ID],Month_Year))

This was my expression initially in the chart, then i got a requirement of 6 months rolling for that chart, i used the below set analysis expression, which is working fine in all expressions except the above one, where i have used aggr

Its not working with the aggr function.

{<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >}.

Please help me to find out how can i do 6 months rolling for this expression

Dimension - Month_Year

avg(aggr(((Sum(a/b))*c),[emp ID],Month_Year))



thanks..


1 Solution

Accepted Solutions
sunny_talwar

May be this

num(Avg({<Month_Year>}Aggr(((Sum({<Month_Year = {"=Date#(Only({1} Month_Year), 'MMM-YYYY') >= AddMonths(Max(TOTAL Date#(Month_Year, 'MMM-YYYY')), -5) and Date#(Only({1} Month_Year), 'MMM-YYYY') <= Max(TOTAL Date#(Month_Year, 'MMM-YYYY'))"}>}a/b))*Only({<Month_Year>} c)), empid, Month_Year)

),'#.##')

View solution in original post

34 Replies
Anonymous
Not applicable
Author

this cant't work because set analysis have text values as input.

If you use >= or <= then you have to give the set analysis a format that the

Automatic Number Interpretation can convert into a numerical value.

Anonymous
Not applicable
Author

you could try expression search instead for example:

{<Month_Year = {"=

(Month_Year>=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')))

and

(Month_Year<=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"})

>}

Anonymous
Not applicable
Author

I dont understand on what you are telling as TEXT .


(Sum({<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >} a/b))


The above expression will display the sum(a/b) as rolling six months in the chart.


Whereas, if i use the same set analysis exp with aggr function

avg(aggr(((Sum({<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >} a/b))*c),[emp ID],Month_Year))


Its not working.



Not applicable
Author

try this

aggr(Sum({<Month_Year ={">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY'))<=$(=Date(addmonths(Max(Month_Year), 0),'MMM-YYYY'))"} >}a/b),[emp ID],Month_Year)

Anonymous
Not applicable
Author

sorry, my mistake, try:

avg(aggr(((Sum({<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >} a/b))

*only({<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >} c)

),[emp ID],Month_Year))

could also be that you have to place the set modifier additionally within avg like

avg({<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >}

aggr(((Sum({<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >} a/b))

*only({<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >} c)


),[emp ID],Month_Year))

Anonymous
Not applicable
Author

Not a problem. Thank you.

Tried your expressions, but it is not working.

Anil_Babu_Samineni

May be this?

avg(aggr(((Sum({<Month_Year = {">=$(=Date(addmonths(Max(Month_Year), -5), 'MMM-YYYY')) <=$(=Date(addmonths(Max(Month_Year), 0),  'MMM-YYYY'))"} >} (a/b)))*c),[emp ID],Month_Year))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

please prepare a sample

Anonymous
Not applicable
Author

Thanks anil,

Its not working