New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Contributor

Stock Analysis

Hi All,

I am working on Stock Analysis.

Where a stock is scanned on dealers in a month.
Data looks like below

Account_ID     Date                     Stockqty

1                    23-07-2017               10

2                    24-07-2017               12

2                     25-07-2017               13

2                      25-07-2017               2

1                    27-07-2017                 9

Expected Result

2                     25-07-2017               15

1                    27-07-2017                 9

whenever I will check for stock it should provide me the stock scanned on the maximum date of each dealer.

Please suggest the way to get this

For now what  I have done is  aggr(Max(Date),Account_ID) to get the maximum date corresponding to each dealer but it is not giving me the Required Quantity!

Tags (2)
1 Solution

Accepted Solutions
Honored Contributor III

Re: Stock Analysis

Hi,

Table:
AccountId,Date,Stockqty
1,23-07-2017,10
2,24-07-2017,12
2,25-07-2017,13
2,25-07-2017,2
1,27-07-2017,9]
;
Join LOAD AccountId,Max(Date) as Date,1 as Flag
Resident Table Group By AccountId;
NoConcatenate
LOAD AccountId,Max(Date) as Date,Sum(Stockqty) as Stockqty
Resident Table Where Flag=1
Group By AccountId;
Drop Table Table;

Regards,

Antonio

8 Replies
Honored Contributor III

Re: Stock Analysis

Hi,

Table:
AccountId,Date,Stockqty
1,23-07-2017,10
2,24-07-2017,12
2,25-07-2017,13
2,25-07-2017,2
1,27-07-2017,9]
;
Join LOAD AccountId,Max(Date) as Date,1 as Flag
Resident Table Group By AccountId;
NoConcatenate
LOAD AccountId,Max(Date) as Date,Sum(Stockqty) as Stockqty
Resident Table Where Flag=1
Group By AccountId;
Drop Table Table;

Regards,

Antonio

Contributor III

Re: Stock Analysis

Hi swetha,

Try this,

=SUM(IF(Date_1=AGGR(nodistinct MAX(Date_1),Account_ID),Stockqty))

Regards,

Valued Contributor

Re: Stock Analysis

Alternatively you can try this:

Dimensions:

Account_ID

aggr(Max(Date), Account_ID)

Expressions:

=Sum({\$<Date={"=Max(Date)"}>}Stockqty)

Esteemed Contributor

Re: Stock Analysis

Do as follow:

Load  date(max(date)) as date,Account_ID,sum(Stockqty) as Stockqty group by

Account_ID

;

load Account_ID,date(Date#(Date,'DD-MM-YYYY')) as date, Stockqty Inline [

Account_ID,     Date,                     Stockqty

1 ,                   23-07-2017     ,          10

2  ,                  24-07-2017    ,           12

2   ,                  25-07-2017  ,             13

2    ,                  25-07-2017,               2

1     ,               27-07-2017,                 9

];

result:

Contributor

Re: Stock Analysis

Hi Antonio,

Can you please send me the sample qvf of this

Honored Contributor III

See Attachment

Contributor

Re: Stock Analysis

Hi Antonio,

Thanks a lot for helping. Solution worked!

Contributor

Re: Stock Analysis

Hi Shweta,

Kindly find the qvf file as per your requirement.

Thanks & regards,

Sumit Kumar Srivastava