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 / Extract SharePoint cal...
Power Automate
Suggested Answer

Extract SharePoint calculated column year & month(name) from file name & Concate in Title

(0) ShareShare
ReportReport
Posted on by 152
Hi All,
 
I have file name type 1:- AR_DOCUMENT_01_2025.
 
I want to extract month & year in SharePoint column 
 
as Month= January
     Year = 2025
Title = AR DOCUMENT-January 2025
 
File Type 2= AR_DOCUMENT_REPORT_01_2025
 
require as Month= January
                 Year= 2025
                 Title = AR DOCUMENT REPORT - January 2025
 
Please help me to split extract the same .
Categories:
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    If the file is always named in the format shown, you can do this:
    These are the expressions used in each Compose action:
    • Compose Split: split(outputs('Get_file_metadata')?['body/NameNoExt'],'_')
    • Compose Date: concat(last(outputs('Compose_Split')), '-', outputs('Compose_Split')[1], '-01')
    • Compose Year: formatDateTime(outputs('Compose_Date'),'yyyy')
    • Compose Month: formatDateTime(outputs('Compose_Date'),'MMMM')
    If you name the compose actions differently, you will need to adjust the expressions accordingly. Also, for the ABC portion of the filename, it could contain any value you want as long as no underscore (_) is part of it.

    These are the final results you asked to be returned:


  • SD29 Profile Picture
    152 on at
    Thanks David for your reply.. Can you please suggest for the below 2 type of file formats as well 
     
    I have file name type 1:- AR_DOCUMENT_01_2025.
     
    I want to extract month & year in SharePoint column & contact them into Title which should below format:---
     
    as Month= January
         Year = 2025
    Title = AR DOCUMENT-January 2025
     
    File Type 2= AR_DOCUMENT_REPORT_01_2025
     
    require as Month= January
                     Year= 2025
                     Title = AR DOCUMENT REPORT - January 2025
  • Suggested answer
    David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    I could have sworn you asked for the file name format of ABC_01_2025, but no matter, the approach is the same. Do everything, I noted below. You just need to modify the expression in the Compose Date action. In my post below, I said to use:
    • concat(last(outputs('Compose_Split')), '-', outputs('Compose_Split')[1], '-01')
    This part of the expression, outputs('Compose_Split')[1], retrieves the second value from the split (the first value is 0). Based on your new name, the month will be the second value and the year will be the third value. For the expressions that follow the Compose Date action, you need to generate the date in the ISO8601 date format (yyyy-MM-dd).
     
    Change the expression to the following and it should work:
    • concat(outputs('Compose_Split')[3], '-', outputs('Compose_Split')[2], '-01')
     
    Just follow this concept. You most likely going to need to use a condition in your flow to check how many items are in the split, which you can use a length expression. It is going to either return four of five from what I can tell. You'll need to adjust the expression accordingly based on the file format.
  • SD29 Profile Picture
    152 on at
     
    Using a SharePoint library...
     
    While using Get file metadata faced error as it showed null values and could not retrieve the file as I was required to specify particular file.... I do not want to statis the code as want it dynamic which should be working for any files..
    Hence used Get file properties, where I specified the library ID...
     
    But now getting error in Compose Split as below:-
     
  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    You will need to show your workflow and how it is triggered. Whatever method you use, you'll need some action that returns the filename, otherwise there is no way to use the expressions. This could vary depending on what you're doing. You just need to adjust the expression on the Compose Split action to replace the highlighted section of the expression with the dynamic value that contains the file name (without the extension): split(outputs('Get_file_metadata')?['body/NameNoExt'],'_')

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…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard