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 / Flow to extract substr...
Power Automate
Unanswered

Flow to extract substring fails to match Switch/Case

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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.
Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 474

#2
11manish Profile Picture

11manish 268

#3
David_MA Profile Picture

David_MA 243 Super User 2026 Season 1

Last 30 days Overall leaderboard