web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : RoVFH/KXL8s2dCKGjHwdnZ
Power Automate - Building Flows
Answered

Setting variables issue

Like (0) ShareShare
ReportReport
Posted on 18 Feb 2024 20:15:10 by 156

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???
  • NM-06090901-0 Profile Picture
    156 on 19 Feb 2024 at 19:27:57
    Re: Setting variables issue

    @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
    156 on 19 Feb 2024 at 19:27:55
    Re: Setting variables issue

    @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 

  • creativeopinion Profile Picture
    10,466 Super User 2025 Season 2 on 19 Feb 2024 at 04:59:07
    Re: Setting variables issue

    @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
    156 on 19 Feb 2024 at 04:55:25
    Re: Setting variables issue

    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,466 Super User 2025 Season 2 on 19 Feb 2024 at 04:44:57
    Re: Setting variables issue

    @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
    156 on 19 Feb 2024 at 04:39:53
    Re: Setting variables issue

    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

     

  • Verified answer
    creativeopinion Profile Picture
    10,466 Super User 2025 Season 2 on 18 Feb 2024 at 21:43:45
    Re: Setting variables issue

    @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
     

     

     

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

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!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete