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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to use starts with...
Power Automate
Answered

How to use starts with and ends with conditional operator inside of first operand?

(1) ShareShare
ReportReport
Posted on by 31

Is it possible to create a single if condition that checks if the element is 6 characters long and starts with and ends with 0?

powerAuto.png

I have the same question (0)
  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @tgut03 !

     

    Use this:

    NathanAlvares24_0-1720801428677.png

    The Bool value in the Starts with can be True or False:

    True indicating Ignore case

    False indicating Case Sensitive

     

    Also make note these expressions when you combine them all need to be just within a pair of % signs.

     

    Code for the if statement:

     

    IF (TextList[Index].Length = 6 AND StartsWith(TextList[Index], 0, False) AND EndsWith(TextList[Index], 0, False)) = $'''True''' THEN
    END

     

     

  • tgut03 Profile Picture
    31 on at

    Thank you for your help Nathan, I've implemented your code but the conditional is storing text that I don't want. Is it possible to slice each index by its first 6 characters and check if it starts and ends with 0?powerAuto.png

  • Verified answer
    NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @tgut03 !

     

    Please see this for reference.

    NathanAlvares24_4-1721019261766.png

     

    Lets say my list contains these items:

    NathanAlvares24_1-1721018938251.png

    Here it can be numbers or text. I just used numbers. Now what you need to achieve from this is that you need to get a slice of each index of first 6 characters and then use that in the if condition to check if it starts and ends with 0.

     

    Slicing can't be done like that in PAD as shown in your pic. There is a dedicated action which can get the subtext of just the first 6 characters of your text. The action is called "Get subtext".

    NathanAlvares24_2-1721019155759.png

     

    This will help me to get the first 6 characters of that text based on index and store it in a variable. Later use this variable, Subtext to check if it starts with and ends with 0.

    NathanAlvares24_5-1721019306793.png

     

    The full code for your reference:

    SET Count TO 0
    LOOP Index FROM 0 TO TextList.Count - 1 STEP 1
     Text.GetSubtext.GetSubtextFromStartTo Text: TextList[Index] NumberOfChars: 6 Subtext=> Subtext
     IF (StartsWith(Subtext, 0, False) AND EndsWith(Subtext, 0, False)) = $'''True''' THEN
     SET Count TO Count + 1
     ELSE
     # Add some actions here
     END
    END

     

    I hope this helps.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 233

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 190

Last 30 days Overall leaderboard