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 / if condition - what is...
Power Automate
Unanswered

if condition - what is the difference

(0) ShareShare
ReportReport
Posted on by 50

I can't see the difference between these two expressions.

I started with the first expression failing due " 'substring' parameters are out of range", but I thought the if condition would make it skip the first condition and therefore not evaluate it. Strangely the second expression works.

If(contains(body('Html_to_text'),'-::-::-::-'),substring(body('Html_to_text'),0,indexOf(body('Html_to_text'),'-::-::-::-')),body('Html_to_text'))

 

substring(body('Html_to_text'),0,If(contains(body('Html_to_text'),'-::-::-::-'),indexOf(body('Html_to_text'),'-::-::-::-'),length(body('Html_to_text'))))

As I said it works now, but I am just curious.

N

EDITED: there was a ) missing at the end of the second expression when I copied it

2nd Edit: Sorry I made a mess in copying the second expression. now it is correct and it works. working late at might ...

Categories:
I have the same question (0)
  • v-yamao-msft Profile Picture
    Microsoft Employee on at

    Hi nsgma,

     

    Please take this doc about workflow definition language for a reference:
    https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language

     

    From the doc we know that:
    Substring will return subset of characters from a string.
    IndexOf will find the index of a value within a string case insensitively.
    Length will return the number of elements in an array or string.
    Contains will return true if dictionary contains a key, list contains value, or string contains substring.

     

    I assume that you want to use the function to return subset of characters from a string, you may need to configure the function to something likes “substring('somevalue-abc-somevalue',10,3)”. The if function will return the values for Start index and Length.

    3.PNG

     

    While if you use the first function, it will not return values for Start index and Length. So the function won’t work.


    Hope it could be a reference for you.


    Best regards,
    Mabel Mao

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 227

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard