Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get 2 colums from 1 column ?

I have column called region

Region

USA

DC

VA

OH

AUS

RT

GY

HA

I want to get 2 fields called country and states

if region = USA,AUS then Country else States.

Country    States

USA         DC

USA         VA

USA         OH

AUS         RT

AUS         GY

AUS         HA

HOW CAN Iget this done.Thank you.

1 Solution

Accepted Solutions
senpradip007
Specialist III
Specialist III

Have a look at this.

Tab1:

LOAD *,

  if(match(Region, 'USA', 'AUS'), Region, peek(Country)) as Country,

  Region as State

Inline [

Region

USA

DC

VA

OH

AUS

RT

GY

HA

];

T2:

NoConcatenate

LOAD

  Country,

  State

resident Tab1

where Country <> State;

DROP Table Tab1;

View solution in original post

5 Replies
MarcoWedel

see your thread

Cross Table ,maybe

regards

Marco

qlikviewwizard
Master II
Master II

Hi,

Use this script:

Data:

LOAD * INLINE [

Region

USA

DC

VA

OH

AUS

RT

GY

HA

];

NoConcatenate

Country:

LOAD Region as Country,Region

Resident Data

where WildMatch(Region,'USA','AUS');

NoConcatenate

State:

LOAD Region as State, 'USA' as Region

Resident Data

where WildMatch(Region,'DC','VA','OH');

join(State)

State1:

LOAD Region as State, 'AUS' as Region

Resident Data

where WildMatch(Region,'RT','GY','HA');

Drop table Data;

Capture.PNG

Anonymous
Not applicable
Author

Hi,

Use Cross table you can achieve your expected result.

Have a look:

Cross Table

Hope it helps!!

senpradip007
Specialist III
Specialist III

Have a look at this.

Tab1:

LOAD *,

  if(match(Region, 'USA', 'AUS'), Region, peek(Country)) as Country,

  Region as State

Inline [

Region

USA

DC

VA

OH

AUS

RT

GY

HA

];

T2:

NoConcatenate

LOAD

  Country,

  State

resident Tab1

where Country <> State;

DROP Table Tab1;

Not applicable
Author

Thank you veyr much