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: 
Anonymous
Not applicable

Top 1

Hi All

I needed help with trying to obtain the lastIDChagedate to a Transactiondate.

Qvw Attached.

Basically i want the last lastIDChagedate against a transaction.

Currently i am getting many.

Eg

On TransactionDate 02/02/2015 The Last LastIDchangedate was 22/06/2007

On TransactionDate 02/07/2015 The Last LastIDchangedate was 22/06/2015

I needed to filter the last ID based on these dates.


In script please not UI

Any ideas please?

Thanks

27 Replies
MK_QSL
MVP
MVP

For TransactionDate 02/02/2015 you have requireddate as 22/06/2016

Now where is 22/06/2016 for 02/02/2015?

Anonymous
Not applicable
Author

Look at Data 2nd Row?

AccountTransactionDateIDLastIDChangeDateMaxDateRequiredDate
102/02/2015105022/06/200722/06/201522/06/2015
102/02/2015123422/06/201522/06/201522/06/2015
102/02/2015142322/06/200722/06/201522/06/2015
102/07/2015105022/06/200709/06/201509/06/2015
102/07/2015123409/06/201509/06/201509/06/2015
102/07/2015142318/08/201009/06/201509/06/2015
MK_QSL
MVP
MVP

Test:

Load * Inline

[

  Account, TransactionDate, ID, LastIDChangeDate

  1, 02/02/2015, 1050, 22/06/2007

  1, 02/02/2015, 1234, 22/06/2015

  1, 02/02/2015, 1423, 22/06/2007

  1, 02/07/2015, 1050, 22/06/2007

  1, 02/07/2015, 1234, 09/06/2015

  1, 02/07/2015, 1423, 18/08/2010

];

Left Join (Test) 

Load  

  Account,  

  TransactionDate, 

  Date(Max(LastIDChangeDate)) as MaxDate  

Resident Test 

Group By Account, TransactionDate; 

 

 

Left Join (Test) 

Load  

  Account,  

  TransactionDate,  

  MaxDate as RequiredDate  

Resident Test; 

MK_QSL
MVP
MVP

It is 22/06/2015 not 22/06/2016.. Check the year!

22/06/2016

Anonymous
Not applicable
Author

okay that was a typo i should have said you have 22/06/2015 but this is still wrong?

Leave it i am working on it

MK_QSL
MVP
MVP

qlikview-2d-and-3d-combined.jpg

This is the output I am getting for your script... Looks like you are doing something wrong at your end...

Script is as below...

Test:

Load * Inline

[

  Account, TransactionDate, ID, LastIDChangeDate

  1, 02/02/2015, 1050, 22/06/2007

  1, 02/02/2015, 1234, 22/06/2015

  1, 02/02/2015, 1423, 22/06/2007

  1, 02/07/2015, 1050, 22/06/2007

  1, 02/07/2015, 1234, 09/06/2015

  1, 02/07/2015, 1423, 18/08/2010

];

Left Join (Test)  

Load   

  Account,   

  TransactionDate,  

  Date(Max(LastIDChangeDate)) as MaxDate   

Resident Test  

Group By Account, TransactionDate;  

  

  

Left Join (Test)  

Load   

  Account,   

  TransactionDate,   

  MaxDate as RequiredDate   

Resident Test; 

Anonymous
Not applicable
Author

Managed to fix this by the following

Test: 

LOAD * INLINE [ 

    Account, TransactionDate, ID,    LastIDChangeDate 

    1, 02/02/2015,  1050,  22/06/2007 

    1, 02/02/2015,  1423,  22/06/2007 

    1, 02/02/2015,  1234,  22/06/2015 

    1, 02/07/2015,  1050,  22/06/2007 

    1, 02/07/2015,  1423,  18/08/2010 

    1, 02/07/2015,  1234,  09/06/2015 

]; 

 

TEST2: 

Load

Account,

TransactionDate,

ID,

LastIDChangeDate,

if(LastIDChangeDate >= TransactionDate, 'Null',LastIDChangeDate) as New

Resident Test; 

Drop Table Test;

Test3:

Load

Account,

TransactionDate,

//ID,

1 as DCF,

max(New) as New

Resident TEST2

group by Account,TransactionDate; 

Drop Table TEST2;

MK_QSL
MVP
MVP

@adil.hussain

So you mean to say my answer was not working ?

You said you want this output..

AccountTransactionDateIDLastIDChangeDateDate i Need
102/02/2015105022/06/200722/06/2007
102/02/2015123422/06/201522/06/2007
102/02/2015142322/06/2007

22/06/2007

102/07/2015105022/06/200709/06/2015
102/07/2015123409/06/201509/06/2015
102/07/2015142318/08/201009/06/2015

As per your script the final output is not having ID and LastIDChangeDate?

Actually you was asking something different and wanting something different..

Anyway as far as you manage to get answer... I am happy..

But request you to raise question properly based on what exactly you want.. You can understand that how much time I have given for your solution and at last came to know that your QUESTION was different than your EXPECTATION !