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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
DeBIe
Post Partisan
Post Partisan

Would like help using function containsstring or search function or ..?

Hi All,

 

Based on a big datasheet I need to be able to filter data that can be related to a car brand / model / license plate format.

I would like to add a conditional column to my datasheet which tells me if a specific column contains a car brand / model / license plate format. A simple true/false would suffice if the value has been found. I have stored all possible car brands and models in a separate excel file, which will be my keyword or search library. I can update this file to make sure that I always have the latest and newest models in the file. After creating this library, I would like to do a search/containsstring in my datasheet which will look into the library to see if it finds any matches. My first problem is that I am not able to point to my library file with all car brands and models because it is in another table. I need to be able to use the library table and column to use as my "FindText" parameter in the formula. This is the formula which doesn't work:

 

IsModel = CONTAINSSTRING(MasterData[Descriptions],Library[CarModels])

 

My second problem is that I also would like to add a column to see if a car license plate format has been found. In my datasheet, there are multiple which identify a license plate. For this, I have also expanded the library file with possible license plate formats. I would like to do the same containsstring or search function to see if I find any matches. I will try to provide you with some example data:

 

Masterdata table

Descriptions
 27/10/2020 - 26/11/2020 1ABC245
: 1-RTE-987
01.02.20 - 29.02.20 1RTE987
01/2021 - 1SYZ213
01/2021 1-UDD-335
02.2020 1PTP162
01.02.20 - 29.02.2012. 2TKR986
01.02.20 - 29.02.201 1SAS947
: 1FGP720-31-01-2020
: 1JQX193-31-01-2020
: 1-TRT-125-31-01-2020

 

Library CarLicenseFormats

A car license plate will always start with the number 1 or 2, then 3 characters, then 3 numbers. In my masterdata descriptions datasheet, this can be delimited by "-". It is not a big problem if I won't be able to tackle everything. But my datasheet is huge, so it would already be amazing if I can filter most of them.

1A2A1-A2-A
1B2B1-B2-B
1C2C1-C2-C
1D2D1-D2-D
1E2E1-E2-E
1F2F1-F2-F
1G2G1-G2-G
etc.etc.etc.etc.

 

The result I would like to achieve would be

 

DescriptionsIsCarLicensePlateIsCarModel
 27/10/2020 - 26/11/2020 1ABC245truefalse
: 1-RTE-987truefalse
01.02.20 - 29.02.20 1RTE987truefalse
01/2021 - 1SYZ213truefalse
01/2021 1-UDD-335truefalse
02.2020 1PTP162truefalse
01.02.20 - 29.02.2012. 2TKR986truefalse
01.02.20 - 29.02.201 1SAS947truefalse
: 1FGP720-31-01-2020truefalse
: 1JQX193-31-01-2020truefalse
: 1-TRT-125-31-01-2020truefalse

 

Thank you very much for your time! Let me know if I need to provide you with additional info!

 

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

This is in Power Query,

Add a custom column and adapt this code for your table/column names:

(f) => List.AnyTrue(List.Transform(TableQ[#"Car Brand"], each Text.Contains(f[Descriptions], _))))

TableQ is the table with the brands in. Car Brand is the column 

I'm not the original writer of the code above so respect to whoever came up with it.

 

----

If you can get that working, the same pattern applies for the 2 other column searches.  You just need to add further custom columns with code that points at the right Table/column

 

Let me know how it goes

View solution in original post

6 REPLIES 6
HotChilli
Super User
Super User

Have a look in the Advanced Editor or the Formula Bar (above the data in Power Query).  See if an extra "each" has been added before the (f) at the start.  It will be in blue text.  Just remove that "each"

Thank you very much! This worked for me and I am getting correct results so far!

I also had to filter out possible nulls in my library file, otherwise, I got the error that null cannot be converted to text.

 

 

HotChilli
Super User
Super User

This is in Power Query,

Add a custom column and adapt this code for your table/column names:

(f) => List.AnyTrue(List.Transform(TableQ[#"Car Brand"], each Text.Contains(f[Descriptions], _))))

TableQ is the table with the brands in. Car Brand is the column 

I'm not the original writer of the code above so respect to whoever came up with it.

 

----

If you can get that working, the same pattern applies for the 2 other column searches.  You just need to add further custom columns with code that points at the right Table/column

 

Let me know how it goes

Hi @HotChilli ,

 

Thank you, I have added the custom column in my Descriptions table (Description column).

 

(f) => List.AnyTrue(List.Transform(Library[#"CarBrand"], each Text.Contains(f[Description], _)))

 

The result is a new column with the highlighted name 'function'.  I am actually not sure what this formula/function does for me? Hopefully, you can explain to me how it works.

 

Thanks!

HotChilli
Super User
Super User

There's a problem with the sample data provided (1st column is all true , 2nd column is all false)

Can you alter or provide some more sample data which shows 2 things:

Descriptions with no license plate, Descriptions with car model.

 

Could you also give us an example of the car brands data file (just a small sample please)?

 

Hi @HotChilli thank you for helping me.

 

My Masterdata table with the column Descriptions (can contain license plate / brand / model / or other)

27/10/2020 - 26/11/2020 1ABC245
: 1-RTE-987
01.02.20 - 29.02.20 1RTE987
01/2021 - 1SYZ213
01/2021 1-UDD-335
02.2020 1PTP162
01.02.20 - 29.02.2012. 2TKR986
01.02.20 - 29.02.201 1SAS947
: 1FGP720-31-01-2020
: 1JQX193-31-01-2020
: 1-TRT-125-31-01-2020
1-1-2021 Lease Mercedes
Audi fuel shell 11-1-2021
Lease Shell period february Opel
1/5/2021-Toyota-Fuel
Lease-Swift-Tank Shell 50
PC Inventory good
Booking App costs
Sales january overview 
Purchase general march 2021

 

My Library looks like

PossibleCarLicensePlateCar BrandCar Model
1AMercedesSwift
1BSprinterZafira
1CVolkswagenVectra
1DFiatQ7
1EOpeletc
1FFord 
1GFerrari 
2Aetc 
2B  
2C  
2D  
2E  
2F  
2G  
1-A  
1-B  
1-C  
1-D  
1-E  
1-F  
1-G  
2-A  
2-B  
2-C  
2-D  
2-E  
2-F  
2-G  
etc  

 

The expected result would be

 

DescriptionsIsLicensePlateIsCarBrandIsCarModelIsCarRelated
27/10/2020 - 26/11/2020 1ABC245TrueFalseFalseTrue
: 1-RTE-987TrueFalseFalse True
01.02.20 - 29.02.20 1RTE987TrueFalseFalseTrue
01/2021 - 1SYZ213TrueFalseFalseTrue
01/2021 1-UDD-335TrueFalseFalseTrue
02.2020 1PTP162TrueFalseFalseTrue
01.02.20 - 29.02.2012. 2TKR986TrueFalseFalseTrue
01.02.20 - 29.02.201 1SAS947TrueFalseFalseTrue
: 1FGP720-31-01-2020TrueFalseFalseTrue
: 1JQX193-31-01-2020TrueFalseFalseTrue
: 1-TRT-125-31-01-2020TrueFalseFalseTrue
1-1-2021 Lease MercedesFalseTrueFalseTrue
Audi fuel shell 11-1-2021FalseTrueFalseTrue
Lease Shell period february OpelFalseTrueFalseTrue
1/5/2021-Toyota-FuelFalseTrueFalseTrue
Lease-Swift-Tank Shell 50FalseFalseTrueTrue
PC Inventory goodFalseFalseFalseFalse
Booking App costsFalseFalseFalseFalse
Sales january overview FalseFalseFalseFalse
Purchase general march 2021FalseFalseFalseFalse

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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