Forum Discussion

talhaparvaiz's avatar
talhaparvaiz
Icon for Helper I rankHelper I
5 years ago
Solved

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

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi talhaparvaiz 

     

    Try to add a new column like this:

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

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi talhaparvaiz 

     

    Try to add a new column like this:

    Group =
    IF (
        ISERROR ( SEARCH ( "ProdA", yourTable[Product] ) ),
        "GroupOther",
        "GroupA"
    )
  • v-luwang-msft's avatar
    v-luwang-msft
    Icon for Community Support rankCommunity 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