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
Anonymous
Not applicable

Looking for a way to show a Custom Column that says Yes if a Value From Row is in Entire Column.

Hello. I'm trying to add a custom column that says
 
if (value in row) is in (entire column) then YES else NO.
 
Is this possible without using Merge?
2 ACCEPTED SOLUTIONS
artemus
Employee
Employee

Sure...

if List.Contains(MyTable[SomeColumn], [RowValue]) then
   "YES"
else
   "NO"

View solution in original post

v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have created a sample for your reference, please check the following steps as below.

1. Convert the column to list as below.

Capture.PNG

 

2. Then we can add a custom column in the table.

=if List.Contains(Table, [RowValue]) then "Yes" else "No"

3.PNG

 

M code for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlSK1QGSECoJTKakpCjFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [RowValue = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"RowValue", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if List.Contains(Table, [RowValue]) then "Yes" else "No")
in
    #"Added Custom"

 

Attached the pbix as well.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

9 REPLIES 9
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have created a sample for your reference, please check the following steps as below.

1. Convert the column to list as below.

Capture.PNG

 

2. Then we can add a custom column in the table.

=if List.Contains(Table, [RowValue]) then "Yes" else "No"

3.PNG

 

M code for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlSK1QGSECoJTKakpCjFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [RowValue = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"RowValue", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if List.Contains(Table, [RowValue]) then "Yes" else "No")
in
    #"Added Custom"

 

Attached the pbix as well.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

THANK YOU!!!

artemus
Employee
Employee

Sure...

if List.Contains(MyTable[SomeColumn], [RowValue]) then
   "YES"
else
   "NO"
Anonymous
Not applicable

Thank you @artemus .  I get errors when trying this. 

 

Expression.Error: We cannot convert the value "Row Value" to type List.   

 

 

I'm working with 100k rows of data.

What are you putting in for MyTable?

 

It should be the name of the previous step in your query.

Anonymous
Not applicable

Thank you @artemus .  I was using the table name.

 

I replaced with previous step and i'm getting an error

 

= Table.AddColumn(#"Expanded DATA_REPEAT", "Caused_A_Repeat", each if List.Contains(#"Expanded DATA_REPEAT",[TICKET_NUMBER], [1st_Ticket]) then "YES" else "NO")

 

Unexpected Error:

There was an error deserializing the evaluation results. The operation might succeed on a retry.

Remove the comma between:

#"Expanded DATA_REPEAT",[TICKET_NUMBER]

Anonymous
Not applicable

Thank you again! @artemus 

 

My file has so many rows of data i think it's unable to perform this lookup. 

Is there a reason why a self merge will not work for you?

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