Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I have a filed values as below:
NAME
A1 is good,B1 is good, c1 is good
A1 is good
B1 is good, A1 is good,
C1 is good, B1 is good, A1 is good
B1 is good
Now, I want to create a field which will have values as below:
A1
B1
C1
so, I can write a count logic and get count of A1 in group and single occurance ex: A1 = 1 (single) and A1= 3 (group)
Hi,
Create a subfield with field Name. Subfield(Name,' ',1) as xyz
Hi,
Create a subfield with field Name. Subfield(Name,' ',1) as xyz
You could SubField() to split NAME by "," and then SubField() again to get the first word in each. For example:
Data:
LOAD *, RecNo() as RecId Inline [
NAME
"A1 is good,B1 is good, c1 is good"
"A1 is good"
"B1 is good, A1 is good,"
"C1 is good, B1 is good, A1 is good"
"B1 is good"
]
;
Labels:
LOAD
RecId,
SubField(Phrase, ' ',1) as Label
where len(Phrase)
;
LOAD
RecId,
Trim(SubField(NAME, ',')) as Phrase
Resident Data
;
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com
@QS21 Please see the below code:
NoConcatenate
Temp:
Load *, RecNo() as RecId
inline [
NAME
A1 is good,B1 is good, c1 is good
A1 is good
B1 is good, A1 is good
C1 is good, B1 is good, A1 is good
B1 is good
] (delimiter is '|');
NoConcatenate
Temp1:
Load SubField(New_Name,' ',1) as Newfield,
RecId
;
Load RecId,
trim(SubField(NAME,',')) as New_Name
Resident Temp;
Drop table Temp;
Exit Script;
Hi Rwunderlich,
Thanks! but I need it to work dynamically. coz, I am trying to create a filed where if I select A1, I should get all occurrences in the tables no matter which position A1 comes (first or middle or last).
Hi Sidhiq,
Thank you but kindly note that I am not looking for only first occurrences. I was able to get the list of all first strings but when I select B1 it will only give me list of B1s which came as first string, it will not give anything if B1 is in middle or last position
Have a look at substringcount()
If you want all the words, then remove the position argument "1" from the Subfield. eg
SubField(Phrase, ' ') as Label
-Rob