cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Select a range of dates in date picker

Hello,

 

I'm trying to sort my data in a range of dates in the date picker. For example being able to select 7/4/21 and select 7/26/21 and get any data that was entered in that time period. And/or being able to have a clickable options like "Last Week" "Last month" "Last 3 months"

 

I'm a beginner so please explain it in detail 🙂

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Anonymous ,

 

I did a simple demo for you.

1\ This is my datasource.

vxiaochenmsft_0-1627610212668.png

 

2\ Add 2 datepicker control 'DatePicker1' and 'DatePicker2'.

Add a gallery control and set its Items property to:

Filter(LIST148,Date_Column>=DatePicker1.SelectedDate&&Date_Column<=DatePicker2.SelectedDate)

vxiaochenmsft_1-1627610369952.png

 

3\ Add a button control and set its onselect property to:

Set(Last_Week_End,DateAdd(Today(),-Weekday(Today()),Days));Set(Last_Week_Start,DateAdd(Today(),-Weekday(Today())-6,Days))

//Create 2 variables

 

Set gallery's Items property to:

Filter(LIST148,Date_Column>=Last_Week_Start&&Date_Column<=Last_Week_End)

// Show last week 

vxiaochenmsft_2-1627610869604.png

 

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

View solution in original post

StalinPonnusamy
Community Champion
Community Champion

Hi @Anonymous 

 

With(
    {
        sData: Filter(
            'SPDataSource',
            IsBlank(FromDate.SelectedDate) || IsEmpty(FromDate.SelectedDate) || Date >= FromDate.SelectedDate,
	    IsBlank(ToDate.SelectedDate) || IsEmpty(ToDate.SelectedDate) || Date <= ToDate.SelectedDate
        )
    },   
	Sort(
		sData, Date, If(SortDesending1, Descending, Ascending)
	) 

)

 

We can add more filters if you need them.

 

If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

View solution in original post

2 REPLIES 2
v-xiaochen-msft
Community Support
Community Support

Hi @Anonymous ,

 

I did a simple demo for you.

1\ This is my datasource.

vxiaochenmsft_0-1627610212668.png

 

2\ Add 2 datepicker control 'DatePicker1' and 'DatePicker2'.

Add a gallery control and set its Items property to:

Filter(LIST148,Date_Column>=DatePicker1.SelectedDate&&Date_Column<=DatePicker2.SelectedDate)

vxiaochenmsft_1-1627610369952.png

 

3\ Add a button control and set its onselect property to:

Set(Last_Week_End,DateAdd(Today(),-Weekday(Today()),Days));Set(Last_Week_Start,DateAdd(Today(),-Weekday(Today())-6,Days))

//Create 2 variables

 

Set gallery's Items property to:

Filter(LIST148,Date_Column>=Last_Week_Start&&Date_Column<=Last_Week_End)

// Show last week 

vxiaochenmsft_2-1627610869604.png

 

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

View solution in original post

StalinPonnusamy
Community Champion
Community Champion

Hi @Anonymous 

 

With(
    {
        sData: Filter(
            'SPDataSource',
            IsBlank(FromDate.SelectedDate) || IsEmpty(FromDate.SelectedDate) || Date >= FromDate.SelectedDate,
	    IsBlank(ToDate.SelectedDate) || IsEmpty(ToDate.SelectedDate) || Date <= ToDate.SelectedDate
        )
    },   
	Sort(
		sData, Date, If(SortDesending1, Descending, Ascending)
	) 

)

 

We can add more filters if you need them.

 

If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,756)