Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

How to create a Column at scripting

Hello All,

I am Trying something like below ,it is Possible to create a column with values CV,PV,ALL.

if(segment='COMMERCIAL','CV',
if(segment='PERSONAL','PV',
if(segment='COMMERCIAL' and segment='PERSONAL','ALL')

)) as SEGMENT

 

I know if we select both CV and PV which is nothing but ALL, ..but User specifically  need  CV,PV,ALL 

 

 

Thanks

Labels (1)
1 Solution

Accepted Solutions
agigliotti
MVP
MVP

You could do this:

...
if( segment='COMMERCIAL', 'CV',
if( segment='PERSONAL', 'PV'
)) as SEGMENT;
...

New_Table:
LOAD * INLINE [
NEW_FIELD, SEGMENT
PV, PV
CV, CV
ALL, PV
ALL, CV
];

and use NEW_FIELD as your filter in UI.

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it

View solution in original post

5 Replies
agigliotti
MVP
MVP

i think your expression below doesn't makes sense.

if(segment='COMMERCIAL' and segment='PERSONAL','ALL')

what does it means?

what are you trying to achieve?

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
kunkumnaveen
Specialist
Specialist
Author

In a sample way, I have a Column Segment which has values COMMERCIAL,PERSONAL   

Now what i am trying to create a derived column with name SEGMENT which should suppose to have  CV,PV,ALL values

Which means

COMMERCIAL => 'CV',

PERSONAL  => 'PV'.

COMMERCIAL+PERSONAL=>ALL

How to achieve this requirement  

kunkumnaveen
Specialist
Specialist
Author

Hi All,

Is my above requirement is feasible or Not 

agigliotti
MVP
MVP

You could do this:

...
if( segment='COMMERCIAL', 'CV',
if( segment='PERSONAL', 'PV'
)) as SEGMENT;
...

New_Table:
LOAD * INLINE [
NEW_FIELD, SEGMENT
PV, PV
CV, CV
ALL, PV
ALL, CV
];

and use NEW_FIELD as your filter in UI.

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
kunkumnaveen
Specialist
Specialist
Author

Hi,

Its worked , thanks for your suggestion.....