Filter my Gallery by Current Month

Iron Contributor

Hi guys,

 

I have a gallery view that contains record from a sharepoint list, in that one there is a field called MBirth, this is a single line text, so How can I filter my list that field? I mean, myfiel being equal to current month.

 

This is the expression that I'm trying to use:
Filter('Birthday and Work Anniversary','Birthday and Work Anniversary'.MBirth = Month(Now))
But it's not working.

 

This is an expression that I have in my workflow and working perfect, so if I could convert it to use in powerapps it would be great.

 

Query filter:
MBirth eq 'fomatDateTime(utcNow(),'MM')'

So, if my record is set to MBirth eq 04 and that's expression return 04, I'll well get all the records.

Could you help me with this?

 

Thanks in advance,

9 Replies

Hi @ADumith , I recommend setting a variable on start for the current month, formatted to match the format in your source list, then after you've set that variable create your collection filtered by that variable. You would than set the collection as the source for the gallery.

@jonlake 

Great idea,

 

I did this:

Screenshot 2022-04-14 164533.png

 

In the items I added this:

 

Screenshot 2022-04-14 164712.png

 

In my list the field is set like a single line text, so mi record has 04 instead of 4.

 

Where is the error? 😞

 

Thanks in advance,

 

Hi @ADumith , immediately after you create the variable on start, add a line to create your collection, something like this: ClearCollect(colBirthDayWorkAnniversary,Filter(birthday_and_workanniversary,mbirth=varMonths));

 

Your gallery object items would then use the newly populated collection (in my example the SharePoint list is named 'birthday_and_workanniversary').

@jonlake 

 

Thanks for your time,

I renamed the list to avoid errors.

So the code in the OnStart method looks like this:
Set(varMonths, Text(Today(),"mm"));
ClearCollect(colBirthDayWorkAnniversary,Filter(EmployeesDirectory,Mbirth=varMonths))

 

Then in the gallery DATA property I put what I understand would be the name of the collection, I mean, colBirthDayWorkAnniversary

 

When I run the apps no record is shown in the gallery. Am I skipping a step?

 

Thanks again,

Hi @ADumith, you need to set the gallery items property to the collection (colBirthDayWorkAnniversary).

@jonlake 

 

I did it, but doesn't show any record

Screenshot 2022-04-15 130336.png

 

Thanks for your support.

Hi @ADumith , click the edit icon (the pencil) and add in label fields and map them to the fields in the collection.

Hi @jonlake

 

The fields are mapped.

Screenshot 2022-04-15 132634.png

 

But I think the problem is elsewhere, look at the images.

 

Screenshot 2022-04-15 132708.png

The collection is not bringing any records, in fact the fields that are shown do not correspond to the list that I have in SharePoint.

Screenshot 2022-04-15 132606.png

 

One question: The declaration of the variable is made in the OnStart (App) method and the collection too or should it be placed in OnVisible (Screen) or do they both go together?

 

Thanks for your patience and support, I'm new to PowerApps.:cry:

 

 

Hi @ADumith , I see you've started a separate continuation thread: Collection not populating