Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
shruthibk
Creator
Creator

Moving Month average

hi i got requirement to find moving month average of most recent month.but it should be done from scripting side.

my requirement is like

 

metricsmobnthyearcounter
aaJun-15676
bbbJul-157676
tttAug-15998
ytytSep-1576
aaJun-1576
bbbJul-1565
tttAug-1565
ytytSep-1545
bbbJun-15

90

expected data model output should be like this for sum

 

metricsmonthyearcurrmonthprevmonth countPrevmonthcout2
aaajun75200
bbbjun9000
bbbjul7741900
tttaug1063774190
ytytsep12110637741

LOAD metrics,

     mobnthyear,

     counter

FROM

[..\dataload\table1.qvd]

(qvd);

NoConcatenate

temp1:

     load

     metrics,

mobnthyear,

     sum(counter) as COUNT

     resident TEM

    group by metrics, mobnthyear;

     //order by mobnthyear desc;

    

      left join(temp1)

     load

     metrics,

     addmonths(mobnthyear,-1) as mobnthyear ,

     sum(counter) as COUNT1

     resident TEM

    //where COUNT1 is notnull,

    group by metrics, mobnthyear

    ;

//     order by mobnthyear desc;

    

      left join(temp1)

    load

      metrics,

     addmonths(mobnthyear,-2) as mobnthyear ,

     sum(counter) as COUNT2

     resident TEM

    

     group by metrics,mobnthyear;

//     order by mobnthyear desc;    

//    

drop table TEM;

i wriiten code like this but i am not finding exam output plz help me to solve this

reggards ,

shruthi

0 Replies