Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

nested if

Hi maxgro swuehl,

Can someone please help me with this nested if condition in the script.

I want to categorize these days into four sub groups.

i.e., >10 , >31, >61, >91
  
I wrote the if condition but its failing in some cases.

if([Days Past Due] >91, '>91',
        if([Days Past Due] ,'>61',
           if([Days Past Due] ,'>31',
             if([Days Past Due] >10 ,'>10',null())))) as [Days Past Due Range], 

5 Replies
swuehl
MVP
MVP

I think you are missing some comparisons in conditions:

if([Days Past Due] >91, '>91',

        if([Days Past Due] >61 ,'>61',

           if([Days Past Due] >31 ,'>31',

             if([Days Past Due] >10 ,'>10',null())))) as [Days Past Due Range],

swuehl
MVP
MVP

Last message sent to moderation:

Check your conditions, you are missing comparisons >61 resp >31 in second and third condition.

Not applicable
Author

Hi,

Ssorry about the typo, but the requirement is, if the [Days Past Due] value is 32. It should come under the '>10' as well as '>31' bucket. Which won't happen as per the above if condition.

MarcoWedel

please create a complete input/output specification instead of opening new threads for the same question.

nested if

Issue in nested if

Issue in nested if

Issue in nested if

thanks

regards

Marco

maxgro
MVP
MVP

like this?

or 4 different fields (>10 field, >31 field, etc...)?

1.png

d:

load * inline [

Days Past Due

10,

32,

62,

92

];

t:

load

  [Days Past Due],

  if([Days Past Due] > 91, '>91') as [Days Past Due Range]

resident d;

load

  [Days Past Due],

  if([Days Past Due] > 61, '>61') as [Days Past Due Range]

resident d;

load

  [Days Past Due],

  if([Days Past Due] > 31, '>31') as [Days Past Due Range]

resident d;

load

  [Days Past Due],

  if([Days Past Due] > 10, '>10') as [Days Past Due Range]

resident d;

load

  [Days Past Due],

  if([Days Past Due] <= 10, null()) as [Days Past Due Range]

resident d;

DROP Table d;