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 Apps / Incorporating if() int...
Power Apps
Answered

Incorporating if() into filter(), date picker questions

(0) ShareShare
ReportReport
Posted on by 100

Hi all, I'm back!

 

First question: I have some filter conditions set on a gallery, but I'm trying to figure out how to incorporate an If() into it. I've looked elsewhere on the board, but I'm having trouble finding something that makes sense.

 

Essentially, if a project (Project.'Project Name') is selected from the dropdown (FP_drp_ProjectName), the gallery displays the correct items. However, I need to include that if that dropdown is blank, return all projects (but still filtered by the other conditions), since at the moment, clearing the dropdown empties the gallery.

 

 

SortByColumns(
 Filter(
 'Time Entries','Time Entries (Views)'.'Time Entries for Approval',
 Date > VarSelectedStartDate && Date < VarSelectedEndDate && 
 Project.'Project Name' = FP_drp_ProjectName.SelectedText.Result
 ),
 "msdyn_date",
 Ascending
)

 

 

Second question: is there a way to get the first date of a week when you pick a date in a DatePicker? I need to set the Sunday of a week as my StartDate variable. As far as I can tell, I can't really change the DatePicker all that much, so I want to ensure that selecting any date in a week starts you on that Sunday.

 

What would be really useful is also being able to get a list of all dates in that week.

 

Thanks! 

Categories:
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @RMDNA :

    Q1:

    Please try this formula:

    SortByColumns(
     Filter(
     'Time Entries',
     'Time Entries (Views)'.'Time Entries for Approval',
     Date > VarSelectedStartDate && Date < VarSelectedEndDate && 
     If(
     FP_drp_ProjectName.SelectedText.Result=Blank(),
     true,
     Project.'Project Name' = FP_drp_ProjectName.SelectedText.Result
     )
     ),
     "msdyn_date",
     Ascending
    )

     Q2:

    Do you want to get the first day of the week in which the date you choose is?
    Do you want Sunday to be the first day of the week?

    If so,please try this formula:

    DateAdd(
     DatePicker1.SelectedDate,
     1 - Weekday(DatePicker1.SelectedDate),
     Days
    )

     Best Regards,

    Bof

  • RMDNA Profile Picture
    100 on at

    Hi @v-bofeng-msft,

     

    Thanks for the assist. I got the date part working, but when using your other formula, the gallery is now empty regardless of the dropdown selection. I get an error of "Blank() = PowerApps encountered an internal error trying to evaluate this expression."

     

    RMDNA_0-1616616846693.png

     

    Does it matter that there's not an explicit "blank" option in the data? I have the dropdown Default set to Blank( ) and a button that triggers Reset(FP_drp_ProjectName) to clear it of any selection.

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @RMDNA :

    There should be an explicit "blank" option in that drop down control.

    For example,my drop down's items property is:

    Table({Value:Blank()},{Value:1},{Value:2})

    23.gif

    Best Regards,

    Bof

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard