Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
drohm002
Creator
Creator

creating new field, group by?

Hi, please see table below.  I would like to create a field that grabs only one score per ID, but that score has to be of the oldest date for that ID.  please help!

So this new field should return 4 for bill, 8 for sam, and 9 for jon.

  

IDscoredate
bill41/1/2016
bill76/1/2016
sam82/1/2016
sam27/1/2016
jon93/1/2016
jon38/1/2016
11 Replies
vishsaggi
Champion III
Champion III

may be try this?

Score:

LOAD ID,

     score,

     date

FROM

[https://community.qlik.com/thread/319081]

(html, utf8, embedded labels, table is @1);

Right Join(Score)

LOAD ID,

     Min(date) AS date

Resident Score

Group By ID;

drohm002
Creator
Creator
Author

does this create a new field or new table or?  how can I get the field I want

vishsaggi
Champion III
Champion III

This will cut the data and give you only those values which has min date.

YOu can try below:

Score:

LOAD ID,

     score,

     date

FROM

[https://community.qlik.com/thread/319081]

(html, utf8, embedded labels, table is @1);

LEFT Join(Score)

LOAD ID,

     Date(Min(date)) AS NewDate

Resident Score

Group By ID;

    

NoConcatenate

Final:

Load *,

     IF(date = NewDate, score) AS NewScore

Resident Score;

Drop Table Score;   

MarcoWedel

Hi,

one solution might be:

QlikCommunity_Thread_319081_Pic1.JPG

table1:

LOAD ID,

    FirstSortedValue(score, date) as FirstScore

FROM [https://community.qlik.com/thread/319081] (html, codepage is 1252, embedded labels, table is @1)

Group By ID;

hope this helps

regards

Marco

drohm002
Creator
Creator
Author

hi Marco, do I use the line below?  like it is in yours...

FROM [https://community.qlik.com/thread/319081] (html, codepage is 1252, embedded labels, table is @1)

afroz_shaik
Contributor III
Contributor III

Hi Danieal,

you have to use "From YourTable".

drohm002
Creator
Creator
Author

what do you mean?? please show example

afroz_shaik
Contributor III
Contributor III

In Script your table must be named something right either it may be Excel, Sql Server eetc.. source. Your load statement looks like this

TableName:

Load ID,

FirstSortedValue(Score,date) As FirstScore

from Source


what is your source?

drohm002
Creator
Creator
Author

my source is a table called PELODDaily.....