Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Sai33
Partner - Creator
Partner - Creator

Generate Max Date based on Two other fields

Hello All,

I've the following Source Table

IDLOCMark IDEvent Date
1AA3001.05.2020
1123501.06.2020
112003.06.2020
2AB5001.05.2020
2DC5520.05.2020

 

Based on LOC and Mark ID fields i would like to generate a New Column Called Last Date.

If LOC is a Numeric Value and Mark ID is 0 than Event Date else Today() as Last Date. So, my expected result is as follows

IDLast Date
103.06.2020
206.06.2020

 

Thanks

Sai

Labels (1)
1 Solution

Accepted Solutions
Taoufiq_Zarra

 I hope this version corresponds to your requirement

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

7 Replies
Taoufiq_Zarra

@Sai33 

whay it's not :

Taoufiq_ZARRA_0-1591478745448.png

for ID=1 we have two cases, one with 0 and one without? How to choose?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Taoufiq_Zarra

unless you mean Max Date, this is the script :

 

Data:

LOAD *,date#([Event Date1],'DD.MM.YYYY') as [Event Date]  INLINE [
    ID, LOC, Mark ID, Event Date1
    1, AA, 30,01.05.2020
    1, 12, 35,01.06.2020
    1, 12, 0,03.06.2020
    2, AB, 50,01.05.2020
    2, DC, 55,20.05.2020
];

output:

load ID,
if(FirstSortedValue(LOC,-[Event Date])*FirstSortedValue([Mark ID],-[Event Date])=0,FirstSortedValue([Event Date],-[Event Date]),date(today(),'DD.MM.YYYY')) as [Last Date] resident Data group by ID;

drop table Data

 

output :

Capture.PNG

 

attached qvf file

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Sai33
Partner - Creator
Partner - Creator
Author

Hello Toufiq,

Thanks for your quick input.

Your Solution here, almost works but i cannot use the FirstSortedValue function as there might be more incoming data later.

I have updated the Source Data and Expected Solution in the attached QVF file.

Thanks and Regards

Sai

Taoufiq_Zarra

Hi Sai,

attached a new version

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Sai33
Partner - Creator
Partner - Creator
Author

Hi Taoufiq,

Your Script is somehow not working with my Real data.

I have updated the QVF file can you please have a look.

Taoufiq_Zarra

 I hope this version corresponds to your requirement

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Sai33
Partner - Creator
Partner - Creator
Author

Thank you Taoufiq