Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Flow to extract substring fails to match Switch/Case

(0) ShareShare
ReportReport
Posted on by

Looked around on here and on the web but can't seem to find similar -- I'm sure there must have been but guess I'm not using sufficiently similar search syntax...

 

Created a flow to extract the last 4 characters from a filename when dropped into a library. Variables hold the filename, total length, number of characters to extract, etc. Filenames follow this convention: 601999999 - 0102.pdf. Once extracted, there's a 6-case Switch action, with the 7th as default. Depending on the value, it sends an email to different people.

 

Flow works just fine at extracting the last four. Result in above example is 0102. It pulls correctly into the Switch.

rb1_1-1593106920734.png

 

However, it doesn't match the matching Case:

 

rb1_2-1593107058032.png

 

I believe it has something to do with text vs number (string v integer), but can't seem to work it out.

 

Here's the Set Variable expression:

substring(variables('FullFileName'),variables('startPosition'),variables('subStringLength'))
 
And the Switch just holds that variable.
 
Should note that, when I go to enter the value in each Case, I get a mismatch error if I just type 0102. It will only be happy with "0102". Seems to make sense, since I'm pulling a sub"string" above.
 
What have I missed? I'm sure it's something stupidly simple.
  • Community Power Platform Member Profile Picture
    on at
    Re: Flow to extract substring fails to match Switch/Case

    Should add that when I named the file 601999999 - RBRB.pdf and put "RBRB" in the Case, everything worked as designed, further leading me to think string vs integer issue.

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1