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 Apps / RETURN STRING CONDITION
Power Apps
Unanswered

RETURN STRING CONDITION

(0) ShareShare
ReportReport
Posted on by 321

It has the following strings: "apple > banana > carrot" and "bee>ant".
At this time, if there are more than two ">", I will return "banana > carrot"
If there is one ">", I want to return the entire string "bee>ant".
How can we solve this?

Bingqiling_0-1701240055546.png

 

If( 
 Len(Label9.Text) - Len(Replace(Label9.Text, ">", "", 1)) >= 2,
 Mid(Label9.Text, Find(">", Label9.Text, Find(">", Label9.Text) + 1) + 1),
 Label9.Text
)

Switch(
 Len(Label9.Text) - Len(Replace(Label9.Text, ">", "", 1)) >= 2,
 Mid(Label9.Text, Find(">", Label9.Text, Find(">", Label9.Text) + 1) + 1),

 Len(Label9.Text) - Len(Replace(Label9.Text, ">", "", 1)) < 2,
 Label9.Text
)

 

Both codes experience errors.
The error in the first IF() code cannot convert the ">" value to a number

The error in the second switch() code is
Invalid argument found in switch statement, invalid argument format (Number). I need a boolean value

Categories:
  • Sundeep_Malik Profile Picture
    6,501 on at

    Hey @Bingqiling 

     

    Try this:

     

    If(
    Len(Label9.Text) - Len(Replace(Label9.Text, ">", "")) >= 2,
    Mid(
    Label9.Text,
    Find(">", Label9.Text, Find(">", Label9.Text) + 1) + 1,
    Len(Label9.Text)
    ),
    Label9.Text
    )

     

    The error could be due to attempting to convert a non-numeric value to a number or providing an invalid argument in the Switch statement.

  • Bingqiling Profile Picture
    321 on at

    HI, @Sundeep_Malik 

    Bingqiling_1-1701241361132.png

     

    Bingqiling_0-1701241104116.png

    An error says ">" cannot be converted into a number,,,

  • Bingqiling Profile Picture
    321 on at

    HI, @Sundeep_Malik 

     

    Is there any other way??

  • Bingqiling Profile Picture
    321 on at

     

    hi @Sundeep_Malik 

    If( 
     Len(Label9.Text) - Len(Replace(Label9.Text, ">", "", 1)) >= 2,
     Right(Label9.Text, Len(Label9) - 1 - Find(">", Label9.Text)) ,
     Label9.Text
    )
    
    Switch(
     Len(Label9.Text) - Len(Replace(Label9.Text, ">", "", 1)) >= 2,
     Right(Label9.Text, Len(Label9) - 1 - Find(">", Label9.Text)) ,
    
     Len(Label9.Text) - Len(Replace(Label9.Text, ">", "", 1)) < 2,
     Label9.Text
    )

     

    And the code in there was wrong, so I corrected it.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard