Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
keerthanagowsi
Contributor III
Contributor III

Above function for current-4th week affecting by filter

Hi everyone, 

I have a requirement to show data for latest 5 weeks. The data should be calculated as follows:

Eg: latest week = 24

Latest - 4th week = 20

So the requirement is 24th week = quantity of 24th week - quantity of 20th week.

Similarly I have to show for latest 5 weeks.

I created an expression as above({week} sum(quantity), 4)q is. This is working fine as long as I apply the filter. Once I apply the filter, my latest 5 weeks occurring correctly, but rest of the weeks are also coming in the view with some values. 

Please help me in finding the solution. 

Thanks in advance, 

Keerthana 

1 Solution

Accepted Solutions
sunny_talwar

May be sorting is not correct from the script... in which case may be this

=Sum(Aggr(Sum(Qty) - Above(Sum({<Week>} Qty), 4), (Week, (NUMERIC))))

 

View solution in original post

19 Replies
Kushal_Chawda

try below

sum(aggr(above( sum({week}quantity), 4),week))*avg(1)

keerthanagowsi
Contributor III
Contributor III
Author

Hi Kush,

Thank you for the reply. But this is not working for me. Instead it is returning 0 for all the records.

 

dieterwoestemeier
Contributor II
Contributor II

Maybe something like this?

Last 4 weeks based on the Today() function.

Sum({<Week=,Week={">=$(=Week(Today())-4)<=$(=Week(Today()))"}>} quantity)

keerthanagowsi
Contributor III
Contributor III
Author

Thank you for the reply, but this is also not working. I cannot use today, because my latest week and current week will not be the same. So this is the set I used

above(Sum({<[Week]=,[Week]={"=[Week]>=$(=Max(total[Week],5))"}>} Quantity),4)

It cannot do the lookup and bring the 4th week value from the current. Instead it is returning null for me.

Kushal_Chawda

Would be able to share sample?

keerthanagowsi
Contributor III
Contributor III
Author

Please find the sample:

Data : 

keerthanagowsi_2-1596441471094.png

 

Requirement:

keerthanagowsi_1-1596441436644.png

 

Kushal_Chawda

try below

=sum(aggr(sum(quantity)- above( sum({<Week>}quantity),4),Week))*avg(1)

 

 

jyothish8807
Master II
Master II

Hi ,

Try like this:

[Table]:
Load *,
previous(previous(previous(previous(Qty)))) as Qty2;
LOAD * INLINE
[
Week,Qty
1,10
2,40
3,50
4,15
5,25
6,35
7,65
8,20
9,30
10,10
](delimiter is ',');

Then in chart simply do Qty-Qty2 and limit dimension to latest 5 week.

 

jyothish8807_0-1596445310852.png

 

Br, 

KC

Best Regards,
KC
Kushal_Chawda

Check the updated expression