Forum Discussion
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
- Anonymous5 years ago
Hi talhaparvaiz
Try to add a new column like this:
Group = IF ( ISERROR ( SEARCH ( "ProdA", yourTable[Product] ) ), "GroupOther", "GroupA" )
3 Replies
- amitchandak
Super User
talhaparvaiz , Create a new column like
Switch( True() ,
[Product] in {"ProdA","ProdBProdA"} ,"GroupA",
[Product] in {"ProdC","ProdE"} ,"GroupOther",
,"GroupOther"
)Also check
- AnonymousNot applicable
Hi talhaparvaiz
Try to add a new column like this:
Group = IF ( ISERROR ( SEARCH ( "ProdA", yourTable[Product] ) ), "GroupOther", "GroupA" ) - v-luwang-msft
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:
Wish it is helpful for you!
Best Regard
Lucien Wang