Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
karan_kn
Creator II
Creator II

Flag field value and last 6 month

Please hep me to create new field using the below logic

(If Status - A or B

Date- Last 6 month? )

Flag - Yes or No

Ex: if(match(Status,'A', 'B') and Last 6 month ,'Yes','No') as Flag

LOAD * INLINE [

    ID, Status, Date

    1, A, 9/16/2017

    2, B, 10/28/2017

    3, C, 11/12/2017

    4, A, 12/13/2017

    5, C, 1/15/2018

    6, D, 2/8/2018

    7, B, 4/22/2018

    8, D, 4/17/2018

    9, B, 5/16/2018

    10, A, 6/2/2018

];

17 Replies
sunny_talwar

Did you forget about the first part of your if statement Match(Status, 'A', 'B')? Have you checked the status for those dates which don't get selected when you select Yes?

sunny_talwar

Or may be you need an OR condition

If(Match(Status, 'A', 'B') or Date >= AddMonths(Today(), -6),'Yes','No') as Flag1,

karan_kn
Creator II
Creator II
Author

I tried this

If(Match(Status, 'A', 'B') or Date >= AddMonths(Today(), -6),'Yes','No') as Flag3,

It exclude only November

Flag3.JPG

sunny_talwar

I am sure November neither have A or B as status and it is def. not within the last 6 months

karan_kn
Creator II
Creator II
Author

My requirement is Last 6 months data contains A and B.

sunny_talwar

How is November in last 6 months? I am sure there may be a way to do this, but I fail to understand

karan_kn
Creator II
Creator II
Author

November should not come, my questions is why Sep and October 2017 also coming, when the condition is Last 6 months.

The result should be Jan 2018 to Jun 2018

sunny_talwar

Because you changed the condition from and to or... so either a or b will be yes or last 6 months. I think Karan you need to go back and understand how if statement works. I clearly see that you are not able to follow the if statement logic. I am not sure how to help you with the if statement part my friend.