Forum Discussion

PeteS's avatar
PeteS
New Member
3 years ago
Solved

Custom column to compare across 2 tables

I'm struggling to get this working..

I need a custom column in table A. Table A has the following 'chargecode' column:

Table A:

 

 

Table B has a list of potential chargecodes in the 'CC' column:

 

 

The custom column would simply be:
If Table A 'Chargecode' is found in Table C 'CC' then show '1', else show '0'

 

Thank you

  • Hi,

    Adapting this post  your solution would be:

    NewColumn =
    VAR _SEL = SELECTCOLUMNS('TableC', "CC", 'TableC'[CC])
    RETURN
    IF('TableA'[Chargecode] IN _SEL, 1, 0)

2 Replies

  • Hi,

    Adapting this post  your solution would be:

    NewColumn =
    VAR _SEL = SELECTCOLUMNS('TableC', "CC", 'TableC'[CC])
    RETURN
    IF('TableA'[Chargecode] IN _SEL, 1, 0)
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi PeteS ,

     

    Please new a custom column like:

    Number.From(List.Contains(#"Table B"[CC],[Chargecode],Comparer.FromCulture(Culture.Current,true)))

    Check  the pbix file.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum