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: 
Anonymous
Not applicable

Splitting a column into 2 separate columns

Hi,

I wanted to split a single column into 2 separate columns in the Script.


Logic:

One column which has field values which contains _H

and another Column which doesn't have _H.

Divide.PNG

Thanks,

SP

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

Try this?

IF(Index([End ID], '_H') = 6, [End ID]) AS NewField2,

IF(Index([End ID]', '_H') <> 6, [End ID]) AS NewField1

OR

IF(FindOneOf(Replace([END ID], '_H', '@'), '@') > 0, [END ID]) AS NewField2,

IF(FindOneOf(Replace([END ID], '_H', '@'), '@') = 0, [END ID]) AS NewField1,

View solution in original post

6 Replies
vishsaggi
Champion III
Champion III

Try this?

IF(Index([End ID], '_H') = 6, [End ID]) AS NewField2,

IF(Index([End ID]', '_H') <> 6, [End ID]) AS NewField1

OR

IF(FindOneOf(Replace([END ID], '_H', '@'), '@') > 0, [END ID]) AS NewField2,

IF(FindOneOf(Replace([END ID], '_H', '@'), '@') = 0, [END ID]) AS NewField1,

vvira1316
Specialist II
Specialist II

See if this will help

trdandamudi
Master II
Master II

May be as below:

Load ID,
IF(Index(ID, '_H')>0, ID) AS [NewField-With H],
IF(Index(ID, '_H')=0, ID) AS [NewField2-Without H];
Load * Inline [
ID
B2700
B2800
B2700_H10
B2800_H10.1
]
;

satishqlik
Creator II
Creator II

May be something like this???

Capture1.JPG

Output:

Capture2.JPG

mostwanted123
Creator
Creator

Try this,

if(wildmatch([End ID],'*_H*'),[End ID]) as EndID1,

if(not wildmatch([End ID],'*_H*'),[End ID]) as EndID2

Regards,

Pratik

Anonymous
Not applicable
Author

Hi,

Try this:

Load ID,

          IF(Index([End ID], '_H') = 6, Max([End ID])) AS NewField2,

          IF(Index([End ID]', '_H') <> 6, Max([End ID])) AS NewField1

From Source

Group By ID

Adding the Max function and group by would ensure that the data is on the same line and therefore won't have multiple lines for each ID