Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Power Apps Sequence Function

(0) ShareShare
ReportReport
Posted on by 2

I have created a sequence function on the app start up to enable me to load a date range This works fine and the date range loads with the correct format in a drop down field, however I need it to default to the current week and not the past week or in my case the week 2 weeks prior based on the selection in the sequence.

 

Is there a way I can add to the sequence that will ensure on load it defaults to the current week and then allows the user to select a previous week from the drop down if required. 

 

I should add this is part of a timesheet app.  Sequence code is

 

Concurrent(
Set(
CurrentUser,
User()
),
Set(
ConcurrentMonday,
DateAdd(
Today(),
-1 * (Weekday(
Today(),
Monday
) -1),
Days
)
),
Set(
weekList,
ForAll(
Sequence(
10,
Day(
DateAdd(
Today(),
-1 * (Weekday(
Today(),
Monday
) - 1),
Days
)
) - 14,
7
),
Date(
Year(Today()),
Month(Today()),
Value
)
)
)
);

 

Ignore the current user section at the very top of the info above. its the section from the Set highlighted in red that set's my date range,

 

In addition I also have the following set on the drop down field on the screen that populates this data, in the 'Items' section of the field setting.

 

AddColumns(
weekList,
"WeekEnd",
DateAdd(
Value,
6,
Days
),
"Week Display",
Value & " to " & DateAdd(
Value,
6,
Days
)
)

 

You can see from the screenshot the date range defaults to 2 weeks prior not this week, e.g. 03.01.2022 - 09.01.2022 etc.

Stuartnt_0-1641470010613.png

 

Thanks in advance

Categories:
  • JR-BejeweledOne Profile Picture
    5,836 Super User 2025 Season 1 on at
    Re: Power Apps Sequence Function

    I think I figured it out for you.   I wasn't able to do it at all originally due to the way Add columns transforms the data source.  

     

    In the initial sequence change the name of the variable you are using for your sequence to something like tempWeekList.

     

    Then add this:

     

     

    ClearCollect(weekList,
    AddColumns(
     tempWeekList,
     "Week Display", Value & " to " & DateAdd(Value,6,Days)
    ))

     

     

    Set your ComboBox Items property to 'weekList' and select the Week Display field.

     

    Set your DefaultSelectedItems to:  (This finds the Monday of the current week and uses it for comparison)

     

     

    [LookUp(weekList, Value = DateAdd(Today(),1-Weekday(Today(),StartOfWeek.Monday),Days)).'Week Display']

     

      

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard