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

Help combining three "IF" nested statements

Hello,

I'm having trouble combining 3 nested if statements.

Each one works fine on its own and each has the same output (1, 0).

Could anyone offer advice?

Many thanks in advance.

=If(PIR_TIME=Timestamp(Aggr(NODISTINCT Min(PIR_TIME), SURGEON)), 1, 0),

// FC on time

If((Time(PIR_TIME) >= '6:54:00') AND (Time(PIR_TIME) <= '8:36:00'), 1, 0),

// b/w 7-830

If(Time(PIR_TIME) >= Time(SCHED_START_TIME)+5/1440, 1, 0))

//PIR: Sched + 5

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Probably spelling or something. Also, the clauses are being badly combined, you should use ANDs to combine the three.

Here you go.

Three IFs Thread145468.jpg

caused by:


=If( (PIR_TIME = Timestamp(Aggr(NODISTINCT Min(PIR_TIME), SURGEON))) AND

     (Time(PIR_TIME) >= '6:54:00') AND (Time(PIR_TIME) <= '8:36:00') AND

     (Time(PIR_TIME) <= Time(SCHED_START_TIME)+5/1440), 1, 0)

Peter

View solution in original post

6 Replies
fkeuroglian
Partner - Master
Partner - Master

Try this, good luck

=If(PIR_TIME=Timestamp(Aggr(NODISTINCT Min(PIR_TIME), SURGEON)), 1, If((Time(PIR_TIME) >= '6:54:00') AND (Time(PIR_TIME) <= '8:36:00'), 1,If(Time(PIR_TIME) >= Time(SCHED_START_TIME)+5/1440, 1,0))))

Not applicable
Author

Try this for nested IFs:

=If(PIR_TIME=Timestamp(Aggr(NODISTINCT Min(PIR_TIME), SURGEON)), 1,

     If((Time(PIR_TIME) >= '6:54:00') AND (Time(PIR_TIME) <= '8:36:00'), 1,

          If(Time(PIR_TIME) >= Time(SCHED_START_TIME)+5/1440, 1, 0)))

MarcoWedel

=If(PIR_TIME=Timestamp(Aggr(NODISTINCT Min(PIR_TIME), SURGEON)), 'FC on time',

    If((Time(PIR_TIME) >= '6:54:00') AND (Time(PIR_TIME) <= '8:36:00'), 'b/w 7-830',

       If(Time(PIR_TIME) >= Time(SCHED_START_TIME)+5/1440, 'Sched + 5'))

      )

    )

Not applicable
Author

Thank you all for your suggestions.

I made a mistake in one of the formulas that I modified: If(Time(PIR_TIME) <= Time(SCHED_START_TIME)+5/1440, 1, 0)

I added the formula in the "Combine Ifs" column.

So for Dr. S, I only want to flag him if he had first case of day (FC of Day), it started the earliest between 7 and 8:30 and if the Patient in Room (PIR) is less than the scheduled start time (adding a 5 minute grace period).

So I only want to show Dr. S' first case beginning at 07:02 because it met all criteria as earliest case in the day.

All other cases should not be flagged.

Do you have a suggestion (I can see if it's a counting issue that the 07:22 case would show too)?

    

SURGEONSched StartPIRFC of DayB/w 7-830PIR <= Sched St + 5Combine Ifs
Dr. S07:0007:021111
Dr. S08:3009:100000
Dr. S07:3007:221111
Dr. S08:1508:050111
Dr. S08:4508:470011
Dr. S09:3009:270011
Dr. S10:0010:140000
Dr. S10:4510:570000
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Probably spelling or something. Also, the clauses are being badly combined, you should use ANDs to combine the three.

Here you go.

Three IFs Thread145468.jpg

caused by:


=If( (PIR_TIME = Timestamp(Aggr(NODISTINCT Min(PIR_TIME), SURGEON))) AND

     (Time(PIR_TIME) >= '6:54:00') AND (Time(PIR_TIME) <= '8:36:00') AND

     (Time(PIR_TIME) <= Time(SCHED_START_TIME)+5/1440), 1, 0)

Peter

Not applicable
Author

Thank you so much! have a great night!