Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Two fields combine into one in script

My company has two Divisions.  A Spa Division and a Bath Division.

I have two fields

[Field A] contains 'Spa' or 'Bath'

[Field B] conatins the identifier 'Both'

what is the eaiser way to get [field C] to contain all there

[Field C]

Spa

Bath

Both

1 Solution

Accepted Solutions
nagaiank
Specialist III
Specialist III

The following script does this. There may be other ways of doing this.

Tab1:

LOAD Company,FieldB, If(FieldB='Both','Spa',FieldA) as FieldA,If(FieldB='Both','Bath') as FieldA1;

LOAD * Inline [

Company, FieldA, FieldB

C1,Spa,Both

C2,,Both

C3,Spa,

C4,Bath,

C5,Bath,Both

C6,,Both

];


Tab2:

NoConcatenate LOAD Company,FieldA as FieldC Resident Tab1 Where Len(FieldA) <> 0;

Concatenate LOAD Company, FieldB as FieldC Resident Tab1 Where Len(FieldB) <> 0;

Concatenate LOAD Company, FieldA1 as FieldC Resident Tab1 Where Len(FieldA1) <> 0;

View solution in original post

7 Replies
Not applicable
Author

Two Questions, in your "field A", do you have blank spaces?or you have both fields A and B all filled?

nagaiank
Specialist III
Specialist III

The following script does this. There may be other ways of doing this.

Tab1:

LOAD Company,FieldB, If(FieldB='Both','Spa',FieldA) as FieldA,If(FieldB='Both','Bath') as FieldA1;

LOAD * Inline [

Company, FieldA, FieldB

C1,Spa,Both

C2,,Both

C3,Spa,

C4,Bath,

C5,Bath,Both

C6,,Both

];


Tab2:

NoConcatenate LOAD Company,FieldA as FieldC Resident Tab1 Where Len(FieldA) <> 0;

Concatenate LOAD Company, FieldB as FieldC Resident Tab1 Where Len(FieldB) <> 0;

Concatenate LOAD Company, FieldA1 as FieldC Resident Tab1 Where Len(FieldA1) <> 0;

Not applicable
Author

javortiz,

[Field A] doesn have an blanks. [Field A] is populated with either 'Spa' or 'Bath'

tanelry
Partner - Creator II
Partner - Creator II

Teach users that selecting both values in field A already means "both"?

anyway, here you go...

// create new dimension table

LOAD * INLINE [

    Field A, Field C

    Spa, Spa

    Bath, Bath

    Spa, Both

    Bath, Both

];

Not applicable
Author

Hi

Just use the field B only which contains both Spa and Bath. No need to merge both and create 3rd one.

Cheers.

Not applicable
Author

Thank you, Your script help me to solve my issue.

Not applicable
Author

Thank you, Your script help me to solve my issue.