Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
MrPatrick
Helper I
Helper I

Query to create column comparing text value to column in separate table.

I have data in a table 'listData', one of the columns is 'status' which contains one of ~40 text values indicating the status of the record.

 

These may contain any of the following (shortened for brevity)

  • Sale
  • NI
  • A
  • NA

I have a second table 'staticData' with a single column 'completedStatuses' that contains a subset of these values that indicate a record is complete. This table contains the following (again shortened)

  • AFAX
  • Sale
  • NI

I would like to create a new column in listData called 'completed' that displays a Y or N (or 1 / 0 or true/false) if the value in the 'status' column in listData is contained in the table/column 'staticData[completedStatuses]'

 

I've run through the list of functions and tried to understand anything that looks likely and get either errors or syntactic failures that I don't understand.

The List.* functions (list.MatchAny, list.contains, list.ContainsAny) all return

 

'Expression.Error: We cannot convert the value "AFAX " to type List.
Details:
Value=AFAX
Type=[Type]

 

where I am assuming it isn't looking at the whole completedStatuses column as the list, just the first cell.

 

Text.Contains gave me some True/False output but it didn't follow any matching pattern I could understand.

 

I've been going round in circles trying to find a way to do this and I'm not getting anywhere. Can someone point me in the right direction?

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello

List.Contains has to be used here. Maybe you are it applying the wrong way.
Here an example how to apply it: List.Contains(staticData[completedStatuses],[status])

Hope it helps

Jimmy

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @MrPatrick 

 

Can you create a sample for both tables?

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution
Jimmy801
Community Champion
Community Champion

Hello

List.Contains has to be used here. Maybe you are it applying the wrong way.
Here an example how to apply it: List.Contains(staticData[completedStatuses],[status])

Hope it helps

Jimmy

Thanks Jimmy, that's worked.

Whats frustrating is that I would've sworn that's what I tried when I first came across the list.contains function. Clearly not though as this is working where it wasn't before.

 

Appreciate your help.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors