Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Ramsingh
Contributor
Contributor

Create new field

Hi All ,

Iam new to Qlik .

Require your help on this .

I have field called "axis" which has values as EA, EB,QW,QE,QR,QT 

I want new field from axis field called as Groupaxis which will have 2 values as Group1 and Group2

Condition: if EA,QW,QE,QR,QT then call Group1 and if EB,QW,QE,QR,QT then call Group2

I tried 

if(match(axis,'EA','QW','QE','QR','QT') ,'Group1'
,
if(match(axis,'EB,'QW','QE','QR','QT') ,'Group2') )as Groupaxis

But when i refresh i get only group1 value in the field Groupaxis . Not sure what i'm doing wrong or let me know other ways if possible .

 

Advance Thanks

Ram

Labels (1)
4 Replies
lironbaram
Partner - Master III
Partner - Master III

hi 

in your expression only QB will be in group2 all other will be in Group1 

the way the if function works is that when the first condition is met the second will not be evaluated 

jonathandienst
Partner - Champion III
Partner - Champion III

You cannot assign values like 'QW' to both Group1 and Group2, so it will only be assigned to the first one in the If(). You may need a different data structure such as two flag fields for Group1 and 2:

if(match(axis,'EA','QW','QE','QR','QT'), 1, 0) as Group1Flag,
if(match(axis,'EB,'QW','QE','QR','QT'), 1, 0) as Group2Flag,

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Vegar
MVP
MVP

I order to get a field value to be associated with multiple you have two approaches.

1. Duplicate the transactions for the transactions containing QW QE QR and QT. Like this.

Data:
LOAD 
   Group,
  'Group1' as  Groupaxis
From Source
Where match(axis,'EA','QW','QE','QR','QT');
LOAD 
   Group,
  'Group1' as  Groupaxis
From Source
Where match(axis,'EB,'QW','QE','QR','QT');

//If you have transactions without Groupaxis then add the rest not matching
LOAD 
   Group,
  'Group1' as  Groupaxis
From Source
Where NOT match(axis,'EA','EB,'QW','QE','QR','QT');

 

2. Create a dimension table associating Group to one or more dimension.

Data:
LOAD 
  *, 
  Group as %group 
From 
  Source;

[Group axis]:
LOAD * INLINE [
Group, Groupaxis
EA, Group1
QW, Group1
QE, Group1
QR, Group1
QT, Group1
EB, Group2
QW, Group2
QE, Group2
QR, Group2
QT, Group2
];

 

Without knowing your scenario I would recommend you to start considering alternative 2. 

Brett_Bleess
Former Employee
Former Employee

You have received a few responses, we would greatly appreciate it if you would return to the thread to review those and if any of them assist in solving your use case, please use the Accept as Solution button to mark the one(s) that helped, and if you did something different, you can post what you did and then mark that post afterward using the button.  Marking things gives the posters credit for the assistance and lets the other Members know what worked.

Here is Help link on Match as well:

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Condi...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.