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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Walid_Abou
New Member

Create a new column based on specific combination of column values.

I want to create a new column that classifies IDs based on whether they are seen in combination with another specific value.

I have tried with IF, IF contains and look-up functions but with no luck. I just get a replication or count of 'SomeValue'. What I want is to set 'Y' or '1' in the new column whenever an ID has 'X' in SomeValue no matter the frequency. 

 

The HasX should be the desired outcome as shown below

 

IDSomeValueHasX?
1 Y
1XY
1 Y
2 Y
2XY
3 N
4 N
4 N
1 ACCEPTED SOLUTION
DOLEARY85
Resident Rockstar
Resident Rockstar

Hi,

 

try this:

 

Column = if(CALCULATE(CONTAINS('Table (5)','Table (5)'[SomeValue],"X"),ALLEXCEPT('Table (5)','Table (5)'[ID]))=TRUE,1,0)
 
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @Walid_Abou 

try to add a column like:

Column = 
VAR _list = 
CALCULATETABLE(
    VALUES(data[SomeValue]),
    data[ID]=EARLIER(data[ID])
)
RETURN
IF(
    "X" IN _list,
    "Y", "N"
)

 

it worked like:

FreemanZ_0-1682431464551.png

 

DOLEARY85
Resident Rockstar
Resident Rockstar

Hi,

 

try this:

 

Column = if(CALCULATE(CONTAINS('Table (5)','Table (5)'[SomeValue],"X"),ALLEXCEPT('Table (5)','Table (5)'[ID]))=TRUE,1,0)
 
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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