Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Setting default selection of ComboBox to a value from different SharePoint list based on current date

(0) ShareShare
ReportReport
Posted on by

Hello, 

 

I have a SharePoint list with period definition (essentially weeks) - defined by 'name' and then 'starting' and 'ending' date

Ajwou_0-1684752746769.png

I would like to use this Sharepoint list in my app, where depending on the current date, 'Week Number' (Combo box) gets filled in (default value) . 

Ajwou_1-1684752890746.png

Please could anyone help?

 

Kind Regards, 

 

Categories:
  • Ajwou Profile Picture
    Ajwou on at
    Re: Setting default selection of ComboBox to a value from different SharePoint list based on current date

    Hello @WarrenBelz , 

    I took your suggestion and further adjusted it to look at the ranges:

    {
    Week:
    LookUp(
    'Periods and Weeks',
    'Start Date' <= DataCardValue5.SelectedDate && 'End Date'>=DataCardValue5.SelectedDate
    ).Week
    }

     

    This seems to work now. Hopefully I am not missing anything. 

     

    Thank you very much @WarrenBelz for your help!

  • Ajwou Profile Picture
    Ajwou on at
    Re: Setting default selection of ComboBox to a value from different SharePoint list based on current date

    Hi @WarrenBelz , 

     

    I have used the code, however noting returns. Is the formula considering the range?

     

    We have a "random" date (in the date picker) and the task is to find in which period this date sits. The date is not  defined in the child SP list exactly, there are only ranges ie:
    Today is 23/05/2023 and the data in the SP list would be Week 5, then period starting date 22/05/2023 and ending date of that period 28/05/2023. So the formula would return Week 5 in this case. 

  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    Re: Setting default selection of ComboBox to a value from different SharePoint list based on current date

    Hi @Ajwou ,

    I think you need it "backwards" from what I posted = the DefaultSelectedItems of the Combo Box

    {
     week:
     LookUp(
     SPList,
     'Start Date' = YourDatePicker.SelectedDate
     ).week
    }

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • Ajwou Profile Picture
    Ajwou on at
    Re: Setting default selection of ComboBox to a value from different SharePoint list based on current date

    Hi @WarrenBelz 

    I tried the suggested workflow, however it didn't work. I think I haven't explained the issue properly. 

    At the moment I have an app, that uses a sharepoint list. Within the app, I have date control, where I can select a date (default set to 'today') and also combobox control, which is linked to another sharepoint list with defined periods (period label, starting and ending date). So what I am trying to achieve to take selected date (today) in the app, find in which period (range in the child SP list) it belongs and return the 'week label' for that period into the combobox.  

  • WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    Re: Setting default selection of ComboBox to a value from different SharePoint list based on current date

    Hi @Ajwou ,

    The DefaultDate (using the names you provided)

    LookpUp(
     SPList,
     name = 'Week Number'.Selected.Week
    ).'Start Date'

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard