Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
Qlik Launches Open Lakehouse and advanced agentic AI experience in Qlik Answers! | LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sassoumani
Contributor II
Contributor II

How to return the last value of my stock by period

Hello everyone, I need your help.

I have a table with the value of my stock per day 

example

Item ID Year Month Day Date StockValue
116 2023 01 01 01/01/2023 100
116 2023 01 31 31/01/2023 90
116 2023 02 02 02/02/2023 20
116 2023 02 27 27/02/2023 50
116 2023 02 14 14/03/2023 550
116 2023 03 31 31/03/2023 700

 

I am looking for a way to display the last stock value for an item according to the time dimension.

Case 1 )
user select only the year 2023
expect result : 700

Case 2 )  
user select the year 2023 and month 02
expect result : 50

Someone can help me pls ?

 

Labels (2)
2 Replies
QGTFS
Contributor III
Contributor III

Hello,

One way to do it would be using set identifier in your expression

For instance :

=Sum({$<[Date_field] ={"$(=Max([Date_field]))"}>)

Basically it will sum every value, grouping by your current selection (represented by $), having the date = to the max date available.

Identifiers can be used when you can aggregate some values, there's this link on the matter :

https://help.qlik.com/en-US/qlikview/May2023/Subsystems/Client/Content/QV_QlikView/ChartFunctions/Se...

It takes a bit of practice but it's great once you get the hang of it.

QGTFS
Contributor III
Contributor III

Sorry I missed a part from the expression =Sum({$<[Date_field] ={"$(=Max([Date_field]))"}>  [Amount])

So that your amount is summed.