cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RobH1
Advocate I
Advocate I

My string contains an (

I have a filename as a string containing among other things "1 (Old" or "2 (Old".   The length and structure of the string may change so I can't use split or substring.

 

In my fx I have:

If( contains( outputs('Compose'), '1 (Old', '1',

If( contains( outputs('Compose'), '2 (Old', '2',

''))

 

It's part of a much bigger line of code finding various bits of the string using contains, every other bit is working fine but this part is failing, I assume because there is an open bracket in the string.

Any advice?  Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
mahoneypat
Solution Sage
Solution Sage

Can you use the replace() function before this step to replace the (s with a unique character?

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Solution Sage
Solution Sage

Can you use the replace() function before this step to replace the (s with a unique character?

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


ekarim2020
Super User
Super User

I think what may be happening here is that the second if statement is missing the false condition?

Try:

if(contains(outputs('Compose'),'1 (Old'),1,if(contains(outputs('Compose'),'2 (Old'),2,'NO MATCH!'))

The if condition requires: If(condition, true, false)

 

Ellis

Hi,  It's not that, it has a false condition, it's just blank with ''.  You are correct though I am missing the ) from my code after (Old' should be (Old') but it still fails.

Thanks, I had thought of that after posting but wanted to avoid it as both ( ) occur throughout the string so I have to replace both with unique characters and re write everything but that and adding the missing ) to my code does work.

Just seems odd that it wouldn't ignore the ( when it is wrapped in '' making it part of the string and I wondered if I was missing something.

Final code now looks like:
Compose = replace( replace( substring( items('Apply_to_each')?['{Name}'],8),'(','^'),')','^')

fx to extract the bit I want =

If( contains( outputs('Compose'), '1 ^Old'),'1', If( contains( outputs('Compose'), '2 ^Old'),'2','')


 

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,086)