Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Syntax help

I have 3 tables, see below and attached. I need create a table of Alerts (first table) with a  Rank and Indicator (If statement). I'm

going to filter on Rank =1. I've been working on this for a while and keep running into issues. The latest attemp is attached but is missing the attempt for Survey2a.

Indicator =  IF(AlertDate - Survey1A_Date <= 10, 'Y', 'N') AS Survey1a_Indicator

Indicator =  IF(AlertDate - Survey2A_Date <= 10, 'Y', 'N') AS Survey2a_Indicator

Rank = Partition by Memberid, /* I believe I need to inlcude incase there are duplicate entries but name Survey name differes Name*/ ,AlertDate, order by SurveyIndicator desc, Survey1aDate

My output should look like below: All data from the alert table

Output:                       Maybe add Ranks in script, not sure what would be best. Eventually will filter of Rank = 1

Memberid  AlertDate    TypeOfAlert    Survey1a_Indicator     Survey2a_Indicator  /*Survey1aRank*//* Survey2aRank*/

    1               1/10/2016       Red                   Y                                                                       1               

    2               1/20/2016       Red                   Y                                                                       1

    3               1/11/2016       Red  /* Blank:Survey1a date is less than AlertDate*/                1

    4               1/12/2016       Green                N                                                                      1

    5               1/10/2016       Green                N                                                                      1

    5               1/10/2016       Green                N                                                                      2 (latest survey date)

    5               1/30/2016       Green                Y                                                                      1

    5               1/30/2016       Green                N                                                                      2

    6               1/5/2016         Red                                                              Y                                                       1

/*Skipping Rows 7-9*/

  10               1/10/2016          Green                                                        Y                                                       1

  10               1/10/2016          Green                                                       N                                                       2

  10                4/1/2016           Green      /* Blank:Survey1a date is less than AlertDate*/                                2

  10                4/1/2016           Green                                                       Y                                                       1

/* If Memberid on both tables,  I need to adjust rank to include if applicable */   

11                      1/1/2016                              Y                                                                        1

11                      1/1/2016                                                                       Y                                                     1

12               /* Represents no Survey data but Alert data*/

13                                                                                 

Alert:  

AlertPKMemberidAlertDateTypeOfAlert
10011/10/2016Red
10121/20/2016Red
10231/11/2016Red
10341/12/2016Green
10451/30/2016Green
10551/10/2016Green
10661/5/2016Red
10771/6/2016Red
10881/7/2016Red
10991/8/2016Green
110101/10/2016Green
111104/1/2016Green

Survey1a:  

MemberidSurvey1DateRegionName
11/11/2016EastSurvey1
21/22/2016EastSurvey1
31/1/2016EastSurvey1
41/25/2016EastSurvey1
52/1/2016EastSurvey1
54/1/2016EastSurvey1

Survey2a:  

MemberidSurvey2DateRegionName
61/6/2016WestSurvey2
710/1/2015WestSurvey2
81/19/2016WestSurvey2
91/9/2016WestSurvey2
101/11/2016WestSurvey2
104/1/2016WestSurvey2
1 Solution

Accepted Solutions
bgerchikov
Partner - Creator III
Partner - Creator III

Hi John,

Please review attachment. The main idea is to sort the data set and use Previous function to generate rank.

Hope it will help

View solution in original post

1 Reply
bgerchikov
Partner - Creator III
Partner - Creator III

Hi John,

Please review attachment. The main idea is to sort the data set and use Previous function to generate rank.

Hope it will help