Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
ajsjoshua
Specialist
Specialist

Week Comparison Problem

Hi all,

I want to compare the orders for all weeks

I have two years of data 2015 and 2016

i am unable to compare 52 week of 2015 and 8 week of 2016.

i am using this expression

=sum({<Year_UP = {$(=Max(Year_UP))},Week_UP = { $(=Max(Week_UP)-8) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

Regards,

Joshua.

28 Replies
ajsjoshua
Specialist
Specialist
Author

Hi Manish,

When user select Week_Up = 1 and Year = 2016, i want to display

 

461201633
462201633
463201633
464201633

tyagishaila
Specialist
Specialist

Below is your expression, In which you are using Max(Week_Up)-8, Whenever Max(Week_Up) will be less than 8 it become -ve.

So you have to use either if condition or modify your expression as per your requirement.

=sum({<Year_UP = {$(=Max(Year_UP))},Week_UP = { $(=Max(Week_UP)-8) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

ajsjoshua
Specialist
Specialist
Author

Hi tyagishaila

How to modify the expression with if statement.

tyagishaila
Specialist
Specialist

Actually your problem is not clear to me.

Plz explain in simple way.

What fields you have and what you want to get from those.

do you want to get data of 8 week back or any thing else?

I understood till now, that if you have week_up value 8 than it gives wrong result.

which week's data you need after selecting 8?

ajsjoshua
Specialist
Specialist
Author

Whenever Max(Week_Up) will be less than 8 it become -ve.

so that i am unable to find the values for

week_Up =8

week_Up =7

week_Up =6

week_Up =5

week_Up =4

week_Up =3

week_Up =2

week_Up =1

so is ther any way to write expresssion like this

=if (GetFiledSelections(Week_UP)=1, sum({<Year_UP = {$(=Max(Year_UP)-1)},Week_UP = { $(=Max(Week_UP)-8) },Week = {"=$(=Max(Week_UP))"},Year_UP=,Month_UP=,Quarter_UP=>}Orders)

,if(GetFiledSelections(Week_UP)=2, sum({<Year_UP = {$(=Max(Year_UP)-1)},Week_UP = { $(=Max(Week_UP)-7) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

,if(GetFiledSelections(Week_UP)=3, sum({<Year_UP = {$(=Max(Year_UP)-1)},Week_UP = { $(=Max(Week_UP)-6) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

,if(GetFiledSelections(Week_UP)=4, sum({<Year_UP = {$(=Max(Year_UP)-1)},Week_UP = { $(=Max(Week_UP)-5) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

,if(GetFiledSelections(Week_UP)=5, sum({<Year_UP = {$(=Max(Year_UP)-1)},Week_UP = { $(=Max(Week_UP)-4) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

,if(GetFiledSelections(Week_UP)=6, sum({<Year_UP = {$(=Max(Year_UP)-1)},Week_UP = { $(=Max(Week_UP)-3) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

,if(GetFiledSelections(Week_UP)=7, sum({<Year_UP = {$(=Max(Year_UP)-1)},Week_UP = { $(=Max(Week_UP)-2) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

,if(GetFiledSelections(Week_UP)=8, sum({<Year_UP = {$(=Max(Year_UP)-1)},Week_UP = { $(=Max(Week_UP)-1) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders)

,sum({<Year_UP = {$(=Max(Year_UP))},Week_UP = { $(=Max(Week_UP)-8) },Week = {"=$(=Max(Week_UP))"},Year=,Month=,Quarter=>}Orders))

)))))))

tyagishaila
Specialist
Specialist

instead of writing 8,7,6,5,4......you can use variable in single expression

in above if condition you are again using same thing Max(Week_Up)-8 if Week_Up =1

as I understood, you need to back 8 weeks,

if(

     Max(Week_Up)<=8,  Year_Up=Max(Year_Up)-1 and Week_Up = 52 - (8 - Max(Week_Up)

)  

ajsjoshua
Specialist
Specialist
Author

Hi

tyagishaila

I modified

if(

     Max(Week_Up)<=8,

    

     Sum({< Year_UP ={$(=Max(Year_UP)-1)}, Week_UP = {"52 - (8 - Max(Week_Up)"} >}Orders),

    

     sum({<Year_UP = {$(=Max(Year_UP))},Week_UP = { $(=Max(Week_UP)-8) },Week = {"=$(=Max(Week_UP))"}>}Orders)

    

    

)

still i am not getting the answer

ajsjoshua
Specialist
Specialist
Author

Hi ,

is there any other way to modify it

if(

     Max(Week_Up)<=8,

   

     Sum({< Year_UP ={$(=Max(Year_UP)-1)}, Week_UP = {"52 - (8 - Max(Week_Up)"} >}Orders),

   

     sum({<Year_UP = {$(=Max(Year_UP))},Week_UP = { $(=Max(Week_UP)-8) },Week = {"=$(=Max(Week_UP))"}>}Orders)

   

   

)

Regards,

Joshua.

ajsjoshua
Specialist
Specialist
Author

Thank u Manish.