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 / Setting variables issue
Power Automate
Answered

Setting variables issue

(0) ShareShare
ReportReport
Posted on by 172

Hi Community,

 

I have a strange issue maybe someone can assist me.I have below part of a flow

 

Capture1.PNGThe two variable are used to set the day and year that the email has arrived as below

FormatDateTime(body('Get_email_(V2)')?['receivedDateTime'],'yyyy')     Variable 2
FormatDateTime(body('Get_email_(V2)')?['receivedDateTime'],'MM')      Variable 3
 
I then use these two variables to create the  folder and then create the file in the same folder as below
Capture5.PNG
 
For the majority of the files this works very well except some files that really cant figure out whats going on.
As you can see from below the variables are initialized with the correct values
Capture3.PNG
but when its time to create the file i get below 
Capture4.PNG
For some reason it creates the file in month 01 instead of 12???
Categories:
  • Verified answer
    creativeopinion Profile Picture
    10,508 Moderator on at

    @Mikellas That's really odd behaviour. In your flow, you can use a single Compose action instead. Initializing and setting variables to store a date isn't necessary in your case. 

    formatDateTime(outputs('Get_email_(V2)')?['body/receivedDateTime'], 'yyyy/MM')

    creativeopinion_0-1708292550448.png

    creativeopinion_1-1708292578090.png

    Hope this helps!

     

    For more flow troubleshooting tips—check out this YT Tutorial: 5 Power Automate Troubleshooting FAQs and Helpful Tips for Creating Better Flows

    In this tutorial I cover:

    ✅ How to troubleshoot a false Condition action result

    ✅ How to get dynamic content when it isn’t selectable from the list of dynamic content

    ✅ How to troubleshoot an Apply to Each action that isn’t looping through

    ✅ How to troubleshoot a skipped Apply to Each action

    ✅ How to troubleshoot a Filter Query

    ✅ How to use a SharePoint yes/no column in a Filter Query

    ✅ How to use Compose actions to troubleshoot a Power Automate flow

    ✅ How to troubleshoot multiple emails being sent

    ✅ How to troubleshoot multiple Teams messages being sent

     

    Hope this helps!


    If I helped you solve your problem—please mark my post as a solution ✅.
    Consider giving me a 👍 if you liked my response! If you're feeling generous— ☕️  Buy me a coffee: https://www.buymeacoffee.com/acreativeopinion

    👉 Watch my tutorials on YouTube
    👉 Tips and Tricks on TikTok
     

     

     

  • NM-06090901-0 Profile Picture
    172 on at

    Hi @creativeopinion and thanks for the help.Wont the compose produce just one output?How would i be able to build the path for the file as i need 2 outputs/variables for day and year?Capture5.PNG

     

  • creativeopinion Profile Picture
    10,508 Moderator on at

    @Mikellas Sorry about that. Use two Compose actions instead. 

    formatDateTime(outputs('Get_email_(V2)')?['body/receivedDateTime'], 'yyyy')

     

    formatDateTime(outputs('Get_email_(V2)')?['body/receivedDateTime'], 'MM')

    If you'd like to level up your Power Automate skills check out this video: Power Automate Beginner Tips and Tricks | 5 Things You Need to Know – Part 1

     

    I cover the following in this video tutorial:

    ✅ Power Automate Beginner Tips and Tricks

    ✅ Why use the Manual Trigger instead of an Automated Trigger

    ✅ 3 Ways a Compose Action can help you build better flows

    ✅ How to Manually Trigger a flow with a specific Date and Time

    ✅ How to return a count of items

    ✅ How to use the top count

    ✅ How to send test emails

    Hope this helps!

    If I helped you solve your problem—please mark my post as a solution ✅.
    Consider giving me a 👍 if you liked my response! If you're feeling generous— ☕️  Buy me a coffee: https://www.buymeacoffee.com/acreativeopinion

    👉 Watch my tutorials on YouTube
    👉 Tips and Tricks on TikTok
  • NM-06090901-0 Profile Picture
    172 on at

    Hi @creativeopinion and thanks for taking the time to help me .I will make 2 compose actions and run it .I will let you know if all is good.Thank you so much!!

  • creativeopinion Profile Picture
    10,508 Moderator on at

    @Mikellas No worries. Because you are creating year/month folders, you might find this YT Tutorial helpful: Streamline 2024: Automate Monthly Folders & Files in Minutes

     

    In this Microsoft Power Automate tutorial, I’m going to show you how to create an Automated Cloud flow that runs on the first day of a new year. We’ll go over how to use the Convert Time Zone action as well as how to use an expression to return the months in a year. I’ll cover three different scenarios on how you can use these actions in various flows:

     

    1️⃣ Create a new folder for the new year for a selected folder. This folder will contain subfolders for each month of the new year.

    2️⃣ Create a file for each month of the new year from a template.

    3️⃣ Create a new notebook section in OneNote for the new year with a page for each month in the year.

     

    ---

     

    IN THIS VIDEO:

    ✅  How to trigger a flow from a selected folder

    ✅  How to create a file from a template

    ✅  How to create a new notebook section in OneNote for the new year with a page for each month in the year

    ✅ How to use the Recurrence trigger

    ✅  How to create dynamic dates

    ✅  How to use a date input in a manual flow trigger

    ✅  How to use the Convert Time Zone action

    ✅  How to use the range() function

    ✅  How to use the concat() function

    ✅  How to use the formatDateTime() function

    ✅  How to group Power Automate actions together

    ✅  How to use the Recurrence trigger

    ✅  How to customize a OneNote Page Name in Power Automate

     

    Hope this helps!

    If I helped you solve your problem—please mark my post as a solution ✅.
    Consider giving me a 👍 if you liked my response! If you're feeling generous— ☕️  Buy me a coffee: https://www.buymeacoffee.com/acreativeopinion

    👉 Watch my tutorials on YouTube
    👉 Tips and Tricks on TikTok

     

     

  • NM-06090901-0 Profile Picture
    172 on at

    @creativeopinion  Thanks for the tutorial it has been really helpful especially with stuff i am doing now.Also the compose actions has the correct output at last !! Thanks for all the help 

  • NM-06090901-0 Profile Picture
    172 on at

    @creativeopinion  Thanks for the tutorial it has been really helpful especially with stuff i am doing now.Also the compose actions has the correct output at last !! Thanks for all the help 

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 Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 423

#2
11manish Profile Picture

11manish 308 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 177

Last 30 days Overall leaderboard