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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
lmit
Creator II
Creator II

Flag changing in tmap

Hi All,

I have a requirement where I need to change flag from y to n based on a condition.my data looks like below
Id;flag
1;y
2;y
1;
My output should be
Id;flag
1;n
2;y
1;y
If ids are same and have a flag value as y then it has to change to n and if the flag is null it has to change to y

Can anyone Suggest a solution, if so would be a great help.

Thanks in advance,
Lmit

Labels (2)
1 Solution

Accepted Solutions
manodwhb
Champion II
Champion II

please give kudos and Accept the solution when you think you're good with it.

View solution in original post

21 Replies
Anonymous
Not applicable

Hello,

 You can use ternary operator for if-else scenario in tMap or join your two tables.

 Condition?value if true:value if false

Best regards

Sabrina

lmit
Creator II
Creator II
Author

Hi Sabrina,,

 

Thanks for your reply . but can you be little bit clear about what you said??

 

Thanks in advance,

lmit

manodwhb
Champion II
Champion II

First sort the data based on Id and create create a Var for current Id and Previous Id and compare the Prevous Var with Current Var equls then y else n. use this way.
lmit
Creator II
Creator II
Author

Hi,

 

Thanks manohar for the reply.

 

the data in file can have n number of rows with same id and other ids which are not same like

 

id,flag

1,Y

2,Y

3,Y

1,

1,Y

 

both the id's 1 with flag Y should be become N and with null should become N

but id's 2 with flag Y should be Y only

 

Thanks,

lmit

 

 

manodwhb
Champion II
Champion II

since you can sort the data based on Id Asc and Flag Asc order in tSortrow,you wil lget in required way and then you can compare in tmap and derive new flag.

 

manodwhb
Champion II
Champion II

If this help please give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

manodwhb
Champion II
Champion II

still you have issue?

lmit
Creator II
Creator II
Author

Yes Manohar,

 

Flag still not changing, after sorting and comparing also the flag is not changing.

 

for both values its changing, i mean for all values where Y is there is getting changed to N

 

Thanks,

Lmit

manodwhb
Champion II
Champion II

Can you show your job design?