Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Blank Formula Help

Hi.

 

I am trying to categorise numerial responses into 3 different categories.

 

If they answered between 0-1 - I want to categorise that as 0-1 Day Active

If they answered between 2-4 - I want to categorise that as 2-4 Days Active

If they answered between 5-7 - I want to categorise that as 5+ Days Active

If the box is not filled - I don't want it to categorise

 

See the example of my data set below, the column in bold is what I need.

NameAnswerCatergory
Mary22-4 Active
Joe55+ Active
John  
 
I have tried the below DAX and it works except it categorises when a cell is left blank where it hasnt been answered as 0-1 Active.
 
Ans_Cat = if ('Table'[Answer] <=1, "0-1 Active", IF(AND('Table'[Answer] >=2,'Table'[Answer] <=4), "2-4 Active", "5+ Active")
 
So i tried this:
Ans_Cat = if (AND('Table'[Answer] <=1, 'Table'[Answer] <> BLANK() ), "0-1 Active", IF(AND('Table'[Answer] >=2,'Table'[Answer] <=4), "2-4 Active", "5+ Active"))
 
But it now seems to categorise the blank sells as 5+ Active... I don't want them to categorise the blank cells at all, I just want the answer to remain blank if they haven't responded to the question.
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    You could use ISFILTER() function.

    Column = IF(ISBLANK('Table'[Answer]),BLANK(),IF('Table'[Answer]<1,"0-1 Active",IF('Table'[Answer]>=2&&'Table'[Answer]<=4,"2-4 Active","5+ Active")))

     

    Best Regards,

    Jay

6 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Community Champion

    Anonymous 

     

    When using an IF, the last argument will be what all other values get coded as, so you need to explicitly define BLANK as BLANK. This will also probably be simpler using a SWITCH function: 

     

    This has no 'alternate result' so should keep blank for blank.

    Ans_Cat =

    SWITCH( TRUE()
    , 'Table'[Answer] <=1, "0-1 Active"

    , 'Table'[Answer] <=4, "2-4 Active"

    , 'Table'[Answer]  > 5, "5+ Active"

    )

     

    If it doesn't work, try: 

    Ans_Cat =

    SWITCH( TRUE()

    , ISBLANK( Table'[Answer] ), BLANK()
    , 'Table'[Answer] <=1, "0-1 Active"

    , 'Table'[Answer] <=4, "2-4 Active"

    , 'Table'[Answer]  > 5, "5+ Active"

    )

     

    • AllisonKennedy's avatar
      AllisonKennedy
      Community Champion

      Anonymous  You may also need to check for empty value (not just blank): 

       

      Ans_Cat =

      SWITCH( TRUE()

      , ISBLANK( 'Table'[Answer] ) ||  'Table'[Answer] = "", BLANK()
      , 'Table'[Answer] <=1, "0-1 Active"

      , 'Table'[Answer] <=4, "2-4 Active"

      , 'Table'[Answer]  > 5, "5+ Active"

      )

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    You could use ISFILTER() function.

    Column = IF(ISBLANK('Table'[Answer]),BLANK(),IF('Table'[Answer]<1,"0-1 Active",IF('Table'[Answer]>=2&&'Table'[Answer]<=4,"2-4 Active","5+ Active")))

     

    Best Regards,

    Jay