Forum Discussion

Mahamood0218's avatar
Mahamood0218
Icon for Helper II rankHelper II
3 years ago
Solved

can not find age buckets

hi,

i am not able to find age Buckets by using if statement ,

could you please suggest from 61 to 90days and >90days.

 

Thanks.

  • age= IF('Date'[age]<=30,"<30days",IF('Date'[age]>=31 && 'Date'[age]<=60,"31 to 60 days",IF('Date'[age]>=61 && 'Date'[age]<=90,"61 to 90 days",IF('Date'[age]>90 ,">90days"))))
     
  • Anonymous's avatar
    Anonymous
    3 years ago

    try this:

     

    Bucket =
    SWITCH(
        TRUE(),
        Days[Days]<30,"<30days",
        Days[Days]<60,"30 to 60 days",
        Days[Days]<90,"60 to 90 days",
        ">90days"
    )

6 Replies

  • age= IF('Date'[age]<=30,"<30days",IF('Date'[age]>=31 && 'Date'[age]<=60,"31 to 60 days",IF('Date'[age]>=61 && 'Date'[age]<=90,"61 to 90 days",IF('Date'[age]>90 ,">90days"))))
     
  • AilleryO's avatar
    AilleryO
    Icon for Memorable Member rankMemorable Member

    Hi,

     

    Or you could do the test the other way (starting with biggest numbers), to make it more simple :

    age buckets = IF('Date'[age]>90,">90days",
    IF('Date'[age]>60,"61 to 90 days",
    IF('Date'[age]>30,"31 to 60 days",
    IF('Date'[age]<30 ,"<30 days"))))

    Hope it helps

      • AilleryO's avatar
        AilleryO
        Icon for Memorable Member rankMemorable Member

        Hi,

         

        Can you tell us more or provide sample data because it should work, maybe a problem with parenthesis or column name (should be [Days] not [Age] ?)...

        age buckets = IF('Table'[Days]>90,">90days",
        IF('Table'[Days]>60,"61 to 90 days",
        IF('Table'[Days]>30,"31 to 60 days",
        IF('Table'[Days]<30 ,"<30 days"))))

        I'm in a train so cannot make proper test but it should work, if your column is type number.

        Let us know

  • Anonymous's avatar
    Anonymous
    Not applicable

    try this:

     

    Bucket =
    SWITCH(
        TRUE(),
        Days[Days]<30,"<30days",
        Days[Days]<60,"30 to 60 days",
        Days[Days]<90,"60 to 90 days",
        ">90days"
    )