Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor II
Contributor II

Removed

 
1 Solution

Accepted Solutions
Highlighted
MVP
MVP

Re: Second value of same id using Apply map

You could create a mapping table with all values by adding a order information part delimited by a arbitrary delimiter not part of your key values ('|' in my sample). Then you can address first, second, etc mapping value per key:

MAP:

MAPPING

LOAD A&'|'&AutoNumber(Recno(),A) as A, B

INLINE

[

A B

1 A

1 B

2 C

3 D

3 E

4 F

] (delimiter is '\t');

LOAD A,

  Applymap('MAP', A&'|2', ApplyMap('MAP',A&'|1')) as Test

  INLINE

  [

  A

  1

  2

  3

  4

  ];

View solution in original post

8 Replies
Highlighted
Partner
Partner

Re: Second value of same id using Apply map

suppose your original table is called T

then do the following:

T2:

mapping

load Column1, FirstSortedValue(Column2,-Column2)

resident T

group by Column1;

drop table T;

hope this helps

I can walk on water when it freezes
Highlighted
Contributor II
Contributor II

Removed

 
Highlighted
MVP
MVP

Re: Second value of same id using Apply map

You could create a mapping table with all values by adding a order information part delimited by a arbitrary delimiter not part of your key values ('|' in my sample). Then you can address first, second, etc mapping value per key:

MAP:

MAPPING

LOAD A&'|'&AutoNumber(Recno(),A) as A, B

INLINE

[

A B

1 A

1 B

2 C

3 D

3 E

4 F

] (delimiter is '\t');

LOAD A,

  Applymap('MAP', A&'|2', ApplyMap('MAP',A&'|1')) as Test

  INLINE

  [

  A

  1

  2

  3

  4

  ];

View solution in original post

Highlighted
Contributor II
Contributor II

Removed

 
Highlighted
MVP
MVP

Re: Second value of same id using Apply map

It's because you are coy-pasting it and '\t' is not working properly in that case. Try using different (comma) separator like:

MAP:

MAPPING

LOAD A&'|'&AutoNumber(Recno(),A) as A, B

INLINE

[

A, B

1, A

1, B

2, C

3, D

3, E

4, F

];

LOAD A,

  Applymap('MAP', A&'|2', ApplyMap('MAP',A&'|1')) as Test

  INLINE

  [

  A

  1

  2

  3

  4

  ];

Highlighted

Re: Second value of same id using Apply map

There are no tab characters between column headers and field values. Either replace the spaces with a tab character, or change this

(delimiter is '\t');


to this


(delimiter is ' ');

Highlighted
Partner
Partner

Re: Second value of same id using Apply map

from the sample data you supplied you can take the max group by first column and do the mapping table

I can walk on water when it freezes
Highlighted
Master III
Master III

Re: Second value of same id using Apply map

Hi,

maybe this

MapTable:
Mapping
LOAD A,LastValue(B) as B Inline [
A, B
1, A
1, B
2, C
3, D
3, E
4, F]

Group By A;

LOAD DISTINCT A,ApplyMap('MapTable',A) as B Inline [
A, C
1, 12
1, 23
2, 34
3, 45
3, 56
4, 67]
;

Regards,

Antonio