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
monishamathew
Regular Visitor

Categorizing a column value into 3 different categories

Hi folks,

I have a requirement in which I need to categorize values in App column in three categories based on the values of DeviceCompliant column. 
If a particular App has both True and False , then the new column should show "Both",otherwise it would be either "true" or "False" value.

I have made a table with dummy data-

AppDeviceCompliant
A

TRUE

BFALSE
AFALSE
CTRUE
BTRUE
DFALSE
ETRUE

 

And Below is the desired result-

AppNew Column
ABoth
BBoth
CTRUE
DFALSE
ETRUE

 

Please let me know if we could achieve it at the query editor or both report and query editor.

2 ACCEPTED SOLUTIONS
ouaelaam
Resolver I
Resolver I

Hello,
Here is a suggestion :
You can do a Group By with Concatenation as exlained here :
https://gorilla.bi/power-query/group-by-to-concatenate-text/

 

Then create a conditional column with a Text.Contains to get the final result.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Hi @monishamathew ,

 

I am sending the measure sample I created with the screenshot.

 

MEASURE = IF(calculate(DISTINCTCOUNT('Table'[New Column]),GROUPBY('Table','Table'[App]))>=2,"Both",SELECTEDVALUE('Table'[New Column]))
EzgiAslankara_0-1672821344186.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


Best regards 🙂

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @monishamathew ,

 

I am sending the measure sample I created with the screenshot.

 

MEASURE = IF(calculate(DISTINCTCOUNT('Table'[New Column]),GROUPBY('Table','Table'[App]))>=2,"Both",SELECTEDVALUE('Table'[New Column]))
EzgiAslankara_0-1672821344186.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


Best regards 🙂

Thanks for the quick response. This works for me.

ouaelaam
Resolver I
Resolver I

Hello,
Here is a suggestion :
You can do a Group By with Concatenation as exlained here :
https://gorilla.bi/power-query/group-by-to-concatenate-text/

 

Then create a conditional column with a Text.Contains to get the final result.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks. This also works for me.

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.

Top Solution Authors
Top Kudoed Authors