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 / 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
    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

Forum hierarchy changes are complete!

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

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 398 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 331 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 203 Most Valuable Professional

Last 30 days Overall leaderboard