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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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