Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
paulyeo11
Master
Master

when user select month = Oct , year = 2012 , it will sum up all data from starting till 2012 Oct

Hi All

I need to compute Stock Amount on hand .

To make thing simple , for Jan 2012 till Jan 2013 , on the first of the month i add Qty 2 , and on 17 of the month i take out Qty 1.

So every month i have Stock Balance Qty 1 , because 2-1=1 . And at the end of 13 month , my stock balance = 13.

I need expression to display Stock balance as below behavious :-

when user select on month=1 year = 2012 , i need the stock balance display 1.

when user select on month=2 year = 2012 , i need the stock balance display 2.

when user select on month=3 year = 2012 , i need the stock balance display 3.

when user select on month=4 year = 2012 , i need the stock balance display 4.

when user select on month=5 year = 2012 , i need the stock balance display 5.

when user select on month=6 year = 2012 , i need the stock balance display 6.

when user select on month=7 year = 2012 , i need the stock balance display 7.

when user select on month=8 year = 2012 , i need the stock balance display 8.

when user select on month=9 year = 2012 , i need the stock balance display 9.

when user select on month=10 year = 2012 , i need the stock balance display 10.

when user select on month=11 year = 2012 , i need the stock balance display 11.

when user select on month=12 year = 2012 , i need the stock balance display 12.

when user select on month=1 year = 2013 , i need the stock balance display 13.

How it will display 13 when i not select month and year.

Paul

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Try this.

 

=Sum({$<date = {"<=$(=Max({$}[date]))"}, month = ,year= >}[Amount])

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

4 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Try this.

 

=Sum({$<date = {"<=$(=Max({$}[date]))"}, month = ,year= >}[Amount])

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
spividori
Specialist
Specialist

Hi.

See the example. Balance table I added to the script in order to get the result.

Hope this helps.

Regards.

paulyeo11
Master
Master
Author

Hi Kaushk

I like your script most , because you give me the result i want. Now i am happy that i am able to implement your script in my actual qv doc. I think it sure work fine.

Paul

paulyeo11
Master
Master
Author

Hi Kaushik

http://community.qlik.com/message/335321#335321

I start a new post , because you already solve my problem using the sample QV doc. Now when i apply your script in my expression it work fine , but i need to get the previous month stock amount , i am not able to do it , can you pls help me.

Paul