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 / Date Filtering a Galle...
Power Apps
Answered

Date Filtering a Gallery for Fiscal Year

(0) ShareShare
ReportReport
Posted on by 244

I'm trying to add a filter to a gallery so that only items within the current fiscal year appear. There is a dropdown with year values on the gallery screen so that as the years pass, they can change the filter to go back and look at previous years' records. 

 

I based my solution off of this article from Matthew Devaney: Power Apps Filter Gallery By Dates In Current Year - Matthew Devaney.

I just modified the dates in the Start and End variables to be the start and end of the fiscal year and added a dropdown with a selection of 10 years to indicate the current (if unchanged) or desired year. The dropdown also has a formula that assigns the current fiscal year value as the default. 

 

However, I cannot get the filter to work. I've tried it exactly as shown (with the exception of my Fiscal Year selection control providing the year value and changes to the Start and End date variable values). I also tried setting it up using global variables which are set when the gallery screen becomes visible or when the Fiscal Year selection is made. I have multiple galleries that will eventually use this control, so global variables will probably be used. 

I also have filters on the gallery to provide only items that the current user has created. This worked fine until I added the date filter. I removed all the filters and applied only the date filters (as mentioned above) and they returned zero records. Removed the date filters and all the appropriate records displayed. The field I am filtering on is from a SharePoint list and is a SharePoint date field set to date only (no time). 

This is the code used for each attempt:
Original working filter

 

Sort(
	Filter(
		'LMS Request - Learning Plus',
/* Users can search for a specific Request ID using the search box */
		StartsWith(
			'Request ID',
			TextSearchBox1.Text
		),
/* Only items created by the user or where the user has been assigned as the Request Owner are visible */ 
		Or(
			'Request Owner'.Email = varCurrentUserEmail,
			'Created By'.Email = varCurrentUserEmail
		)
	),
	Modified,
	SortOrder.Descending
)

 

 

Filter with added Start and End Date variables

 

Sort(
	Filter(
		'LMS Request - Learning Plus',
/* Only dates falling between Start and End dates should be included in the gallery */
		'Request Date' >= varStartDate,
		'Request Date' <= varEndDate,
/* Users can search for a specific Request ID using the search box */
		StartsWith(
			'Request ID',
			TextSearchBox1.Text
		), 
/* Only items created by the user or where the user has been assigned as the Request Owner are included in the gallery */
		Or(
			'Request Owner'.Email = varCurrentUserEmail,
			'Created By'.Email = varCurrentUserEmail
		)
	),
	Modified,
	SortOrder.Descending
)

 

 

Variable Population in Screen OnVisible

 

Set(
 varStartDate,
 Date(
 FYValue.Selected.Title,
 4,
 1
 )
);
Set(
 varEndDate,
 Date(
 FYValue.Selected.Title,
 3,
 31
 )
);

 

With the original filters and the date filters included, records are returned as if the date filters don't exist. With only the date filters in place, no records are returned. 

 

Any help in understanding what I'm doing wrong is greatly appreciated!

Categories:
I have the same question (0)
  • WiZey Profile Picture
    3,023 Moderator on at

    Hello @CCJones ,

     

    Following your formula, your variables are set with those values:

     

    varStartDate = Date(FYValue.Selected.Title, 4, 1)
     = Date(2024, 4, 1)
     = 01/04/2024
    
    varEndDate = Date(FYValue.Selected.Title, 3, 31)
     = Date(2024, 3, 31)
     = 31/03/2023

     

    So your "Filter()" is actually using a condition like:

     

    varStartDate <= 'Request Date' <= varEndDate
    01/04/2024 <= 'Request Date' <= 31/03/2024

     

    ... Which is not working, of course.

     

    I suggest using "DateAdd()" so "varEndDate" actually becomes superior to varStartDate.

  • CCJones Profile Picture
    244 on at

    Hi @WiZey,

    Thanks for the response. Not sure I understand though. 

    My variables are set (either through the Screen OnVisible by default or by selection of a specific Fiscal Year) and then compared in the filter as snipped below (the full filter formula is in my original post):

     

     

    /* Only dates falling between Start and End dates should be included in the gallery */
    		'Request Date' >= varStartDate,
    		'Request Date' <= varEndDate,

     

     

    Request Date must be >= varStartDate and Request Date must be <= varEndDate. I'm not following how you see it as varStartDate <= Request Date <= varEndDate.

    Relatively new to PowerApps and coding in general, so not sure how to use DateAdd() as you mentioned.

  • Verified answer
    CCJones Profile Picture
    244 on at

    I think I just figured it out. Stupidity on my part. I didn't have a "+1" in my varEndDate year calculation so it was making the end date 12/31/23 instead of 12/31/24.  Works perfectly now. Duh.

    Thanks for the aid!

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard