Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
vipingarg23
Creator
Creator

First Occurrence of the filed

Hi Team,

I have below data

IDDesc
1234A
1234B
1234C
5678T
5678J

 

Need Output as below (I need desc based on First occurrence of ID):

 

IDDesc
1234A
5678T
Labels (4)
2 Solutions

Accepted Solutions
Vegar
MVP
MVP

You could use EXISTS(). It is quite effective. See example below, it will give you the desired result.

DATA:
LOAD * INLINE [
ID	Desc
1234	A
1234	B
1234	C
5678	T
5678	J]
(delimiter is '	')
WHERE NOT Exists(ID)
;

 

View solution in original post

Kushal_Chawda

 

Data:
LOAD ID,DESC
FROM YourQVD;

// Sort your data on next load to get the correct values

Final:
LOAD *
where Flag=1;
LOAD *,
     if(rowno()=1 or ID<>previous(ID),1,0) as Flag
resident Data
order by ID,Desc;

drop table Data;

 

View solution in original post

2 Replies
Vegar
MVP
MVP

You could use EXISTS(). It is quite effective. See example below, it will give you the desired result.

DATA:
LOAD * INLINE [
ID	Desc
1234	A
1234	B
1234	C
5678	T
5678	J]
(delimiter is '	')
WHERE NOT Exists(ID)
;

 

Kushal_Chawda

 

Data:
LOAD ID,DESC
FROM YourQVD;

// Sort your data on next load to get the correct values

Final:
LOAD *
where Flag=1;
LOAD *,
     if(rowno()=1 or ID<>previous(ID),1,0) as Flag
resident Data
order by ID,Desc;

drop table Data;