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: 
vinod22kv
Creator
Creator

Help need in creating an dimension in script level

Hi,

i am trying to create the dimension like 3 column.

If name = vinod and if id has repetied then count of that id's. I want this in script level.

Nameidvinod
vinod12
vinod12
vinod23
vinod23
vinod23
Siva30
Siva40
Siva40
Gopi50

 

Thanks and Regards,

Vinod.

1 Solution

Accepted Solutions
Hariharan_S
Contributor II
Contributor II

Hi

Try this code.

table1:
load * Inline
[name,id
vinod,1
vinod,1
vinod,2
vinod,2
vinod,2
siva,3
siva,4
siva,4
gopi,5];
Map_Tab:
Mapping
Load Distinct name,count(name) as NameCount
resident table1 group by name;
Final_Table:
Load *,Applymap('Map_Tab',name,'No Count') as NameCount
resident table1;
Drop table table1;

View solution in original post

2 Replies
zhadrakas
Specialist II
Specialist II

not the best solution. But it should work for you:

TEST:
LOAD * INLINE [
Name, id
vinod, 1
vinod, 1
vinod, 2
vinod, 2
vinod, 2
vinod, 3
Siva, 3
Siva, 4
Siva, 4
Gopi, 5
]
;

left join
Load Name,
id,
count(if(Name='vinod', id)) as count_id
Resident TEST
GROUP BY Name, id
;

left join
Load Name,
id,
count(if(Name='vinod' and count_id>1, id)) as vinod
Resident TEST
GROUP BY Name, id
;

Hariharan_S
Contributor II
Contributor II

Hi

Try this code.

table1:
load * Inline
[name,id
vinod,1
vinod,1
vinod,2
vinod,2
vinod,2
siva,3
siva,4
siva,4
gopi,5];
Map_Tab:
Mapping
Load Distinct name,count(name) as NameCount
resident table1 group by name;
Final_Table:
Load *,Applymap('Map_Tab',name,'No Count') as NameCount
resident table1;
Drop table table1;