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: 
paulyeo11
Master
Master

How to remove previous month stock amount ?

How to remove my Previous month stock amount ?

Hi All

I have a Table which is working fine.

Due to Previous month data is not consider as D/O not release. So i need to remove Previous month amount.70.74 & 94.61.

1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi,

Try below,

sum({$<month-={$(=Num(Month(AddMonths(Today(),-1))))}>} [TOTAL_AMT])/1000

View solution in original post

9 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Try with something like:

Sum({$ <mymonth={'$(>=(month(totay()))'}> }Amount)

paulyeo11
Master
Master
Author

Enclosed my QV doc. which explan more in detail .

paulyeo11
Master
Master
Author

Hi Ale

I try below code it return nul val :-

Sum({$ <Month={'$(>=(Month(Today()))-1'}> }[TOTAL_AMT])

Any alternative ?

Paul

Anonymous
Not applicable

Hi,

Try below,

sum({$<month-={$(=Num(Month(AddMonths(Today(),-1))))}>} [TOTAL_AMT])/1000

paulyeo11
Master
Master
Author

Hi Satyadev

Your script work fine. But when i use it in my actual QV doc , which is not working.

My actual QV doc is reading QVD file from the file i have attach here. So i think it is due to i cannot use AddMonths , it is possible just using SET command ? like Mr Ales approach.

Paul

Anonymous
Not applicable

Hi Paul,

AddMonths is QlikView function, you can use it in your script. Basically I am subtracting one month from current month by using AddMonths function and comparing and removing it from the field called "month". Check if you have "month" column in your application.


You may not see past month data by using Ales script and if you are looking for same thing you can use Ales script. Remember, you should not use Month(Today())-1 as it will give you "0" when you are in Jan month and that's the reason I am using AddMonths(Today(), -1).

paulyeo11
Master
Master
Author

Hi Saty

Thank you vey much your expression now working fine. ( This issue i encounter few time ) .

By the way thank you very much for your help.

it is possible to move one more step further , which is assist me modify the code , by using the SET analysis , so that user can click on year 2013 month Dec , so they are able to view the Amount till 2013 Dec. As now i can only remove the previous month amount. As my need is also remove 3 month ago. Hope you can help me.

Paul

Anonymous
Not applicable

So basically you are looking for below three SETs to be merged together in single script?

1) Remove previous month data

Sum({$<month-={$(=Num(Month(AddMonths(Today(),-1))))}>} [TOTAL_AMT])


2) Calculate YTD base on year and month selection

Variable1 =>  vSelectedYear=Year(Max(Date))

Variable2 => vSelectedMonth=Month(max(Date))


Sum({<Year={$(vSelectedYear)},Month={'<=$(vSelectedMonth)'} >} TOTAL_AMT)

3) Remove last three months data

Sum({$<month-={$(>=Num(Month(AddMonths(Today(),-3)))<=Num(Month(AddMonths(Today(),-1))))}>} [TOTAL_AMT])


paulyeo11
Master
Master
Author

Hi Saty

Thank you for your expression , i have tested it is not i need , in order to make thing simple , i start new post.

Paul