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 variable values
Power Automate
Answered

Setting variable values

(0) ShareShare
ReportReport
Posted on by 8

Is there a way to set a variable to a value using a function or formula in PAD?  For example, I want to create a variable named BeginDate that is set to the first day of the previous month and then another variable named EndDate to be the last day of the previous month.  These would then be used to pass to a reporting application as the date range to run report with.

 

Thanks.

I have the same question (0)
  • Henrik_M Profile Picture
    2,021 Super User 2024 Season 1 on at

    No. There are no functions or formulas. You need to do it with actions. Try pasting this code into your flow:

     

    Display.SelectDate DateDialogFormat: Display.DateDialogFormat.DateOnly IsTopMost: True SelectedDate=> SelectedDate
    Text.ToDateTime Text: $'''01-%SelectedDate.Month%-%SelectedDate.Year%''' DateTime=> TextAsDateTime
    DateTime.Add DateTime: TextAsDateTime TimeToAdd: -1 TimeUnit: DateTime.TimeUnit.Days ResultedDate=> EndDate
    Text.ToDateTime Text: $'''01-%EndDate.Month%-%EndDate.Year%''' DateTime=> BeginDate
  • Rocko Profile Picture
    8 on at

    Thank you for the reply. I am new to Power Automate/PAD and struggling to try to get what I think are basic things to work.  I am currently evaluating this tool as a cheaper option than my current RPA solution.

     

    Where exactly would I paste this code?  I am working entirely in the desktop app.  All the searching I have done has shown using functions/expressions in the web interface.  Am I even wrong in assuming that everything can be done in the desktop app? I am on the verge of giving up and just writing this off as being overly complex compared to my current tool.  As an example, my current tool already has predefined date variables ("FirstDayPriorMonth", "LastDayPriorMonth",etc).  All I have to do is send those as inputs to my SSRS report parameters and then have it click "View Report" and all is good.  

     

    Thanks again for the help!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Rocko , you can directly paste the @Henrik_M  code in PAD development canvas.

    It will convert the above code to PAD actions.

     

    sakula1996_0-1612733080603.png

     

    Hope this helps 🙂

     

  • Rocko Profile Picture
    8 on at

     

    Thanks again Henrick_M....this gets me half way there.  The End Date (last day of prior month) is the same as the Begin Date.  I have done my best to figure out how to manipulate the logic you provided but I am not having any luck.

     

    Rocko_0-1612793827285.png

     

  • GanCW Profile Picture
    237 on at

    @Anonymous ,

    How to get to this development canvas ?

  • Verified answer
    GanCW Profile Picture
    237 on at

    Rocko,

    You can accomplish this in PAD.

    1. Get current date

    2. Last day of the prev month = current date - day number

    3. New date = current date - 1 month

    3. First day of the previous month =  new date - day number + 1

     

    GanCW_1-1613037778737.png

     

     

  • Rocko Profile Picture
    8 on at

    Thank you GanCW!  This got me what I was looking for.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 784

#2
Valantis Profile Picture

Valantis 581

#3
Haque Profile Picture

Haque 545

Last 30 days Overall leaderboard