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
ConwayA
Frequent Visitor

create custom column using one column as a list

I have a table with two columns Submitter email and Manager email.  How would I create a custom column which will display TRUE if the submitter email is found anywhere in the Manager email.   

as shown below.  The submitter email could be anywhere in the Manager email or not at all.

 

submitter emailManager emailLeader of Leader 
email 1email 8TRUE
email 2email 9TRUE
email 3 email 1FALSE
email 4email 2FALSE
1 ACCEPTED SOLUTION
goncalogeraldes
Super User
Super User

Hello there @ConwayA ! You can check if this works for you:

Leader of Leader =
VAR _sub =
    SELECTEDVALUE ( [submitter email] )
VAR _list =
    DISTINCT ( [Manager email] )
RETURN
    IF ( _sub IN _list, TRUE (), FALSE () )

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

hi 
you can also create a calculated column 

Column = IF(Sheet2[submitter email] in VALUES(Sheet2[Manager email]),TRUE(),FALSE())
 
if this post helps, accept this as a solution
KNP
Super User
Super User

In Power Query (Transform data) paste the below code into the 'Advanced Editor' of a blank query.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "i45WSs1NzMxRMFTSgbIslGJ1YKJGcFFLJFFjBbiwIZKwCVzUSCk2FgA=",
          BinaryEncoding.Base64
        ),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [#"submitter email" = _t, #"Manager email" = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(
    Source,
    {{"submitter email", type text}, {"Manager email", type text}}
  ),
  list = #"Changed Type"[Manager email],
  Custom1 = Table.AddColumn(#"Changed Type", "custom", each List.Contains(list, [submitter email]))
in
  Custom1

Hope this helps.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
ConwayA
Frequent Visitor

I feel like I am missing something here. Like identifying the table I am pulling the new columns from. 

so how do I make this happen from an existing table in my report.  

For me the data is in the All Employee Table

Can you show me the structure of the table in your report (without any sensitive data)?

And paste your existing Power Query code for that query?

I don't quite follow what you mean.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
ConwayA
Frequent Visitor

I have not shared previously so not sure what you are asking for exactly.  below is a screen shot of the report.   the two colums exist in the All Employees table.   the Leader of leaders table was the blank table I created and put the code into. but the code only built my example table again. 

 

i need it to build from the All employees table so when it is update the leader of leader table updates as well. 

 

ConwayA_0-1644435011809.png

 

The code I gave you was just an example of the "how".

The steps that matter are...

list = #"Changed Type"[Manager email]

This turns the Manager email column into a list for searching.

 

And the...

Custom1 = Table.AddColumn(#"Changed Type", "custom", each List.Contains(list, [submitter email]))

This uses the 'list' to search the submitter email.

Columns and steps will need to be renamed to suit obviously.

 

If you're still having issues, if you copy the code from the 'Advanced editor' for the "All Employees" table and paste it here, I'll be able to name the steps better. (make sure to obfuscate any sensitive data)

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
goncalogeraldes
Super User
Super User

Hello there @ConwayA ! You can check if this works for you:

Leader of Leader =
VAR _sub =
    SELECTEDVALUE ( [submitter email] )
VAR _list =
    DISTINCT ( [Manager email] )
RETURN
    IF ( _sub IN _list, TRUE (), FALSE () )

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

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.

Top Solution Authors
Top Kudoed Authors