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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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.
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

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")))

1.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

6 REPLIES 6
v-jayw-msft
Community Support
Community Support

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")))

1.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
AllisonKennedy
Super User
Super User

@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"

)

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@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"

)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

amitchandak
Super User
Super User

@Anonymous , if answer is a column it should work

 

Switch ( True() ,
'Table'[Answer] <=1, "0-1 Active",
'Table'[Answer] <=4, "2-4 Active"
, "5+ Active")

 

 

But if it is a measure try for segmentation

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k


@amitchandak wrote:

@Anonymous , if answer is a column it should work

 

Switch ( True() ,
'Table'[Answer] <=1, "0-1 Active",
'Table'[Answer] <=4, "2-4 Active"
, "5+ Active")

 

 

But if it is a measure try for segmentation

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k


@amitchandak You have not tested for blank values, so the result of your formula will give "5+ Active" if they don't fill in the field, since that's the 'alternate result' you gave in the SWITCH.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Hi there.

 

That DAX still categorisies when a cell under the Answer Column is blank as 0-1 Active.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.