Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

vinod22kv
Contributor

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
New Contributor II

Re: Help need in creating an dimension in script level

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
Valued Contributor II

Re: Help need in creating an dimension in script level

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
New Contributor II

Re: Help need in creating an dimension in script level

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