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
Darko_Giac
Helper II
Helper II

Creating a Grouping Within IDs with DAX

Hi all,

 

I'm working with a fairly large survey data set and am just struggling slightly with finding a way to categorize respondents into certain groups depending on their response choice.

 

The response options include ADHD, OCD, VisualImpairment, MotorImpairment, Dysgraphia, and Dyslexia. 

 

The respondents might have duplicate rows, so I would like to categorize any respondent who chose either ADHD or OCD into Group 1, and respondents who chose anything else into Group 2 (using DAX)

 

I know I need to use the Filter function, but not quite sure how to nest it.

 

I've attached a workbook which will hopefully provide further clarity.

 

 

TestWorkbook

 

Any help/advice is greatly appreciated!

Currently using Office 365 ProPlus

 

Darko

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Darko_Giac

 

You can use a column like

 

Column =
IF (
    CALCULATE (
        DISTINCTCOUNT ( Table1[DxGrouping] ),
        ALLEXCEPT ( Table1, Table1[ID] ),
        Table1[DxGrouping] IN { "ADHD", "OCD" }
    ),
    "Group 1 & 2",
    "Group 2"
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

 

I am assuking that Column1 shows your expected result.  What does Group 1 & Group 2 mean? Why is Student 1 falling under Group 1 & Group 2?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Zubair_Muhammad
Community Champion
Community Champion

@Darko_Giac

 

You can use a column like

 

Column =
IF (
    CALCULATE (
        DISTINCTCOUNT ( Table1[DxGrouping] ),
        ALLEXCEPT ( Table1, Table1[ID] ),
        Table1[DxGrouping] IN { "ADHD", "OCD" }
    ),
    "Group 1 & 2",
    "Group 2"
)

Regards
Zubair

Please try my custom visuals

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.