Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
mhmmd_srf
Creator II
Creator II

Need to calculate prior week value

Hi All,

Greeting of the day.

I need your help on the below requirement.

User will select a Date. Lets say it is 10th May 2016. The graph will show the data by hour.

So it will show data for 00.00 to 23.00 (24 hour).--- this is my X axis.

in Y axis I need to show 2lines

a> it will show the value for current selection.

b> it will calculate last 4 Tuesday's data. As 10th May is Tuesday.

So I am creating below variables:

SET v_DATE = GetFieldSelections([M_DATE]);

Set v_DATE7 = Date(Date#($(v_DATE),'MM/DD/YYYY') - 7);

Set v_DATE14 = Date(Date#($(v_DATE),'MM/DD/YYYY') - 14);

Set v_DATE21 = Date(Date#($(v_DATE),'MM/DD/YYYY') - 21);

Set v_DATE28 = Date(Date#($(v_DATE),'MM/DD/YYYY') - 28);

and I am trying to use the below expression :

For Current Date selection: Sum({$<'$(=v_DATE)'>}DLV_LINE_CNT) -- this is working fine.

Similarly, Sum({$<'$(=v_DATE7)'>}DLV_LINE_CNT) or Sum({$<'$(=v_DATE14)'>}DLV_LINE_CNT) is not working.

I thought to do in this way:

Sum({$<'$(=v_DATE7)'>}DLV_LINE_CNT) + Sum({$<'$(=v_DATE14)'>}DLV_LINE_CNT) + Sum({$<'$(=v_DATE21)'>}DLV_LINE_CNT) + Sum({$<'$(=v_DATE28)'>}DLV_LINE_CNT)

Could anyone suggest on this?

Thanks in advance.

1 Solution

Accepted Solutions
phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

Attached is the updated.

I have created two new variables (v_DATE_NEW, v_DATE7_NEW) and updated the expressions. !

View solution in original post

13 Replies
phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

you should try with this...

SET v_DATE = GetFieldSelections([M_DATE]);


SET v_DATE = '=max([M_DATE])';

Set v_DATE7 = Date(Date#($(v_DATE),'MM/DD/YYYY') - 7);

Set v_DATE14 = Date(Date#($(v_DATE),'MM/DD/YYYY') - 14);

Set v_DATE21 = Date(Date#($(v_DATE),'MM/DD/YYYY') - 21);

Set v_DATE28 = Date(Date#($(v_DATE),'MM/DD/YYYY') - 28);

For Current Date selection: Sum(DLV_LINE_CNT)  or Sum({$<M_DATE={'$(=v_DATE)'}>}DLV_LINE_CNT)

Sum({$<M_DATE={'$(=v_DATE7)'}>}DLV_LINE_CNT) + Sum({$<M_DATE={'$(=v_DATE14)'}>}DLV_LINE_CNT) + etc....


here key is to have the FIELD = {'YOUR VALUE'}

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Mohammad,

You may find this app useful in working out how to approach this:

QlikView App: Set Analysis - Prior Period Comparison

Steve

mhmmd_srf
Creator II
Creator II
Author

Hello Phaneendra,

Thanks for your replay.

I tried your approach. But the thing is:

1. When I am dragging one Text item and putting the expression like $(v_DATE7). It is not capturing the desired date that is selected date minus 7 days. It is showing invalid dimension. And the chart was showing the Fact for selected date, not for selected date minus 7.

2. In my approach that is using GetFieldSelections (M_DATE) was capturing the selected value but was not calculating the figure.

Please advise.

Thanks,

Sarif

mhmmd_srf
Creator II
Creator II
Author

Hi Phaneendra,

Even the first expression Sum({$<M_DATE={'$(=v_DATE)'}>}DLV_LINE_CNT)  for current selection is not working.


Please help.


Thanks,

Sarif

phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

Can you share a sample app?

Thanks

Phani

mhmmd_srf
Creator II
Creator II
Author

Hi Phani,

I am doing in Qliksense. So if I upload this in Qlik cloud and share the link with you. Would you be able to check that?

Thanks,

Sarif

mhmmd_srf
Creator II
Creator II
Author

Hi Phani,

I am attaching the POC file. In Qlikview it is working fine. However if I implement the same code in Qliksense , it is not working.

Is it Qlikview syntax and Qliksens syntax is different?

Sorry, I could not send you the Qliksense app. I tried to upload in Cloud. But could not do so.

Thanks in advance,

Sarif

mhmmd_srf
Creator II
Creator II
Author

Hi Phani,

I have uploaded the Qliksense app in Cloud. Below is the link:

https://qlikcloud.com/edit/5732199438c2b40100f78da7

Thanks a lot for all your time...

Thank you so much for your help and co operation.

Thanks,

Sarif

phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

Can you publish to shared cloud? or download that QVF ans send it over?