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
talhaparvaiz
Helper I
Helper I

New column with values based on another column

Hi,

 

I have a table that looks something like this

 

Product 

ProdA          

ProdBProdA   

ProdC

ProdDProdB

ProdE   

 

I want to add a new column and set the value to GroupA if any of the row has ProdA in it, otherwise, I want to set it GroupOther.

 

My desired output is something like this

 

Product                   Group

ProdA                      GroupA        

ProdBProdA            GroupA   

ProdC                      GroupOther

ProdE                       GroupOther

 

Please advise how to accomplish it

 

Thanks in advance

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @talhaparvaiz 

 

Try to add a new column like this:

Group =
IF (
    ISERROR ( SEARCH ( "ProdA", yourTable[Product] ) ),
    "GroupOther",
    "GroupA"
)

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @talhaparvaiz ,

You can use the following measure:

Group = var test1=FIND("ProdA",MAX('Table'[Product ]),,0)  return IF(test1=0,"GroupOther","GroupA")

 

 

Then you will see the below:

v-luwang-msft_0-1614153982281.png

 

 

Wish  it is helpful for you!

 

 

Best Regard

Lucien Wang

 

Vera_33
Resident Rockstar
Resident Rockstar

Hi @talhaparvaiz 

 

Try to add a new column like this:

Group =
IF (
    ISERROR ( SEARCH ( "ProdA", yourTable[Product] ) ),
    "GroupOther",
    "GroupA"
)
amitchandak
Super User
Super User

@talhaparvaiz , Create a new column like

 

Switch( True() ,
[Product] in {"ProdA","ProdBProdA"} ,"GroupA",
[Product] in {"ProdC","ProdE"} ,"GroupOther",
,"GroupOther"
)

 

Also check

https://www.youtube.com/watch?v=gelJWktlR80

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.