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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Unique Values with Multiple Conditions

Hi everyone, 

 

I'm wondering if there is a way to group by unique values in one column and still conduct analysis on the other columns. Looking at the sample data below, I am trying to group by case, and create a new column that will be either "yes" or "null" with the condition that a drug either appears twice for a case OR has a numerical value (i.e., not QTOF under the screen column). 

 

Screen Shot 2022-09-01 at 1.39.30 PM.png

In this example, case A would be null for all drugs, case B would be yes for all drugs, case C yes only for advil, and case D yes for all. (see below)

 

Screen Shot 2022-09-01 at 1.45.24 PM.png

Is there a way I can do this? Thanks in advance!

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

You can add a column with below DAX. Modify table name per your need. Power BI does not support merging cells like in Excel, so it will show a "yes" or "null" value on every row.  

Column = 
VAR _condition1 = IF(CALCULATE(COUNT('Table (2)'[Case]),ALLEXCEPT('Table (2)','Table (2)'[Case],'Table (2)'[Drug])) > 1, 1, 0)
VAR _condition2 = IF(IFERROR(VALUE(RIGHT('Table (2)'[Screen],1)),-1) = -1, 0, 1)
RETURN
IF(_condition1=1 || _condition2=1, "yes", "null")

vjingzhang_0-1662371295219.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

You can add a column with below DAX. Modify table name per your need. Power BI does not support merging cells like in Excel, so it will show a "yes" or "null" value on every row.  

Column = 
VAR _condition1 = IF(CALCULATE(COUNT('Table (2)'[Case]),ALLEXCEPT('Table (2)','Table (2)'[Case],'Table (2)'[Drug])) > 1, 1, 0)
VAR _condition2 = IF(IFERROR(VALUE(RIGHT('Table (2)'[Screen],1)),-1) = -1, 0, 1)
RETURN
IF(_condition1=1 || _condition2=1, "yes", "null")

vjingzhang_0-1662371295219.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Anonymous
Not applicable

Hello,

 

I am trying this out now and it is telling me "Too many arguments were passed to the COUNT function. The maximum argument count for the function is 1."

Hi @Anonymous 

 

Did you miss the right parenthesis next to Case column?

 

IF(CALCULATE(COUNT('Table (2)'[Case]),ALLEXCEPT('Table (2)','Table (2)'[Case],'Table (2)'[Drug])) > 1, 1, 0)

 

Best Regards,
Community Support Team _ Jing

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.