web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Partial String Match a...
Power Automate
Unanswered

Partial String Match against a SQL column

(0) ShareShare
ReportReport
Posted on by

Hey Guys,

 

In SQL I have a table which has a table called dbo.MovieNames which contains a single Column called 'MovieNames' - These are approved names that are written in the correct format. 

 

An example movie name in the correct format:

 

Star Wars: Episode V - The Empire Strikes Back

 

In Power Desktop Automate i have a process which processes a Movie Name input and puts it in %MovieName% but ideally, I want to do a partial string lookup of the movie name obtained and match it against my approved name list as the name obtained via the flow isn't always formated correctly, for example:

 

Star Wars - The Empire Strikes Back

 

or 

 

Star War's Episode V - The Empire Strikes Back

 

Any suggestions on how this can be accomplished would be much appreciated!

 

Thanks. 

 

I have the same question (0)
  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    So you have a table with correct, validated names: dbo.MovieNames

    Then you have a code that does some logic, and as part of the logic it stores "value" in %MovieName% variable?

    And your goal is to ensure that the "value" is validated against dbo.MovieNames before it is stored in %MovieName%.

     

    Did I understand you correctly? If yes, then perhaps simple SQL SELECT with WHERE would work for you?

     

    1. Do whatever you today to obtain "value" but you might need to update the code so the "value" is in a format that is best to do a search in your DB

     

    2. Add SQL that could look like that:

     

    Select [MovieName]
    FROM [dbo.MovieNames]
    WHERE [MovieName] LIKE '%%%value%%%';

     

     

    So if your "value" = The Empire Strikes Back

    SQL would match <any string>The Empire Strikes Back<any string>

    And SQL would return items such as:

    Star Wars: Episode V - The Empire Strikes Back

    Star Wars: Episode VI - The Empire Strikes Back 2

    Star Wars: Episode X - The Empire Strikes Back 10

    and so on..

     

    3. Check whether variable returned by SQL is empty or not and take action based on that.

     

    Or perhaps, check if you could use some other unique identifier instead of value, if available:

     

    1. Instead of using movie title, use unique identifier and assign it to %SKU%

    2. Do SQL select

     

    SELECT [MovieName]
    FROM [dbo.MovieNames]
    WHERE [SKU] = '%SKU%';

     

    3. Now you should have a correct movie name assigned to your variable returned by SQL

     

     

    I always search for unique attributes, or go with regex as a last resort.

     

  • Community Power Platform Member Profile Picture
    on at

    Hello,

     

    Thanks for your reply!

     

    Your understanding of what i have and what i'm trying to achieve is correct. 

     

    Unfortunately the SKU option isn't possible. 

     

    With regards to the LIKE codition in the SQL query, I don't think this will do what i need it to do. Specifying %%%value%%% would indeed match a movie in the lookup that has different text before or after 'value' BUT if the value is different then surely it wouldn't match right?

     

    For example:

     

    If i submitted a query that had

     

    %%%The Empire Strikes Back%%%

     

    but the Correct name was:

     

    %%%The Empire: Strike's Back%%%

     

    Would it still match?

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    It would not match "The Empire: Strike's Back" - you would need to get familiar with RegEx and come up with pattern that would work for your movies

     

    What you could also do is to try to "normalize" the titles before you compare, but I'm not sure this is best approach:

     

    1. Remove all white space, all of characters such as ' and : and other non letter rubbish in value

    So you end up with: "TheEmpireStrikesBack"

    2. Expand your SQL to include REPLACE to the same set of characters before you compare

     

    Here are some articles about regex and replace, but remember, what works for SQL server might not necessary work  in PAD

    https://learn.microsoft.com/en-us/sql/ssms/scripting/search-text-with-regular-expressions?view=sql-server-ver16

    https://learn.microsoft.com/en-us/sql/t-sql/functions/replace-transact-sql?view=sql-server-ver16

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard