What am I doing wrong?

Hello

I’m trying to display bills based on the month the user selects. I have created a state that displays the month and year like this: December 2023.

Then I created a repeating group that displays all bills, and I’m trying to filter out the ones that are not in the currently selected month. But it’s not working. Can anyone tell me what I am doing wrong? Thanks

1 Like

One thing is not using the upload image for the post properly…

Does your data type of Bills have a data field that is of type date?

yes due date is a date field.

Screenshot 2023-12-28 104134

Thats where the problem is.

‘Due Date’ is a specific date. ‘Current Month’ is (I assume) a date rounded down to the month (eg 1st Oct 2024 12:00 am).
The two can only be equal if the due date is on the first of the month.

To do what you are trying to do, you will have remove the search constraint that uses ‘=’ and use two search constraints instead:

Constraint 1
Due date ≥ Text Current Month’s currentmonth
Constraint 2
Due date < Text Current Month’s currentmonth+months:1

This will return all bills that have a due date greater than or equal to the first of the selected month, but also less than the first of the next month.

@Daniel90 as time goes by you’ll end up with issues because of different years.

Add data fields for the month as a number and the year as a number…then use the constraints of a search to first extract from selected dates the month and year and use those to match against constraints for the month and year data fields

Adding new data fields and filtering using that also works.

But why would filtering over a month range cause issues with different years?

That didn’t work. As you can see in the screenshot, it shows bills from December and January. If I change the date from December to January, it shows bills from February.

Screenshot 2023-12-28 114004

It looks like ‘currentMonth’ is not the first of the month like I had assumed, it looks like it’s anchored to current date/time instead.

You can fix that by adding :rounded down to month at the end of both the constraints.

That worked. Thanks!

January 1 - January 31 2023 filtering by month range will return results for January 1 - January 31 2022 as well as every other year that has data in the system.

@Daniel90 add in the data fields I mentioned, then on your search constraints look at your date you have at the top in blue (December 2023) use that DATE and use the function of extract month and extract year within the search constraints to match against the data field for month and year as I mentioned.

I tried doing the same to the bill-paid repeating group, but that didn’t work. Is there a different approach?

You’re using due date equals:

Yes as Adam said, you accidentally used ‘=’ instead of ‘<’ :slight_smile:

How come? Is this a bug? I tested it out and it doesn’t seem to be happening to me.

1 Like

Sorry you are correct. I was thinking in lines of a repeating group for months to show the number of bills for that month. Your approach for this use case works just fine to have only one month (ie: date) selected to filter off.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.