Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Suggested answer

Birthday gallery filter acting weird at month end.

(0) ShareShare
ReportReport
Posted on by 273

Hey everyone, hope you're all doing well.

The following code corresponds to the items property of a gallery that should display the next three upcoming birthdays. It works fine until we reach the end of the month, when it starts showing birthdays from the next month instead of only showing those from the current month.

FirstN(
    Sort(
        Filter(
            ForAll(
                Filter(
                    colusers,
                    birthday <> "MM/DD",
                    !IsBlank(displayName)
                ),
                With(
                    {
                        birthMonth: Value(
                            Left(
                                birthday,
                                Find(
                                    "/",
                                    birthday
                                ) - 1
                            )
                        ),
                        birthDay: Value(
                            Right(
                                birthday,
                                Len(birthday) - Find(
                                    "/",
                                    birthday
                                )
                            )
                        ),
                        nextBirthday: Date(
                            If(
                                Date(
                                    Year(Today()),
                                    Value(
                                        Left(
                                            birthday,
                                            Find(
                                                "/",
                                                birthday
                                            ) - 1
                                        )
                                    ),
                                    Value(
                                        Right(
                                            birthday,
                                            Len(birthday) - Find(
                                                "/",
                                                birthday
                                            )
                                        )
                                    )
                                ) < Today(),
                                Year(Today()) + 1,
                                Year(Today())
                            ),
                            Value(
                                Left(
                                    birthday,
                                    Find(
                                        "/",
                                        birthday
                                    ) - 1
                                )
                            ),
                            Value(
                                Right(
                                    birthday,
                                    Len(birthday) - Find(
                                        "/",
                                        birthday
                                    )
                                )
                            )
                        )
                    },
                    {
                        user: ThisRecord,
                        displayName: displayName,
                        mail: mail,
                        officeLocation: officeLocation,
                        nextBirthday: nextBirthday,
                        birthMonth: birthMonth
                    }
                )
            ),
            nextBirthday > Today()
        ),
        nextBirthday
    ),
    3
)

 

For example, if I have birthdays on May 30th and none on the 31st, the gallery should only display up to May 30th and not start showing June birthdays.

In theory, it should be enough to add one more condition to the filter, but when I do that, I start seeing the birthdays from the 30th plus the same ones from May 1st and 2nd.

What I'm looking for is for the gallery to always show the next three upcoming birthdays from the current month only, without displaying next month's birthdays even when we've reached the end of the current month.

Any ideas?

Thanks!

 
  • WarrenBelz Profile Picture
    147,509 Most Valuable Professional on at
    Birthday gallery filter acting weird at month end.
    If you simply want the next three birthdays in the current month - assuming they are text values in the format "MM/DD"
    With(
       {
          _Data: 
          AddColumns(
             colUsers,
             _Day,
             Value(Last(Split(birthday, "/")).Value),
             _Month,
             Value(First(Split(birthday, "/")).Value)
         )
       },
       FirstN(
          Filter(
             _Data,
             _Month = Month(Today()) && _Day >= Day(Today()) 
          ),
          3
       )
    )
    
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Suggested answer
    Michael E. Gernaey Profile Picture
    42,661 Super User 2025 Season 1 on at
    Birthday gallery filter acting weird at month end.
     
    I'd like to verify, the attribute is a string MM/DD not year?
    Also, you say 3 birthdays, but don't you really mean all birthdays, across 3 days? Since you might have many?
     
    After you answer I will write you the proper expression I just want to make sure.
    One thing to keep in mind is... doing a sub-level complex delegated find (or not) is pretty complex. My plan is to give you an easier model if I understand for sure, and see your question to my question.
     
    I would also ask... 
    1) is there any filters, or ability to change the month or start date or birthdays etc? or is it always just Today?
    2) we may need to take into account UTC and how the data is stored in Entra versus what the locale is for someones PC etc etc
  • ADumith Profile Picture
    273 on at
    Birthday gallery filter acting weird at month end.
     
    I actually removed that filter since I don't need it anymore. Just to give you some context - I'm pulling that collection from our Active Directory, which has a custom attribute set up for birthdays.
     
    This is the right formula:
     
    FirstN(
        Sort(
            Filter(
                ForAll(
                    colusers,
                    With(
                        {
                            birthMonth: Value(
                                Left(
                                    birthday,
                                    Find(
                                        "/",
                                        birthday
                                    ) - 1
                                )
                            ),
                            birthDay: Value(
                                Right(
                                    birthday,
                                    Len(birthday) - Find(
                                        "/",
                                        birthday
                                    )
                                )
                            ),
                            nextBirthday: Date(
                                If(
                                    Date(
                                        Year(Today()),
                                        Value(
                                            Left(
                                                birthday,
                                                Find(
                                                    "/",
                                                    birthday
                                                ) - 1
                                            )
                                        ),
                                        Value(
                                            Right(
                                                birthday,
                                                Len(birthday) - Find(
                                                    "/",
                                                    birthday
                                                )
                                            )
                                        )
                                    ) < Today(),
                                    Year(Today()) + 1,
                                    Year(Today())
                                ),
                                Value(
                                    Left(
                                        birthday,
                                        Find(
                                            "/",
                                            birthday
                                        ) - 1
                                    )
                                ),
                                Value(
                                    Right(
                                        birthday,
                                        Len(birthday) - Find(
                                            "/",
                                            birthday
                                        )
                                    )
                                )
                            )
                        },
                        {
                            user: ThisRecord,
                            displayName: displayName,
                            mail: mail,
                            officeLocation: officeLocation,
                            nextBirthday: nextBirthday,
                            birthMonth: birthMonth
                        }
                    )
                ),
                nextBirthday > Today()
            ),
            nextBirthday
        ),
        3
    )
     
    Any idea?
     
    Thank you, 
  • ronaldwalcott Profile Picture
    3,810 on at
    Birthday gallery filter acting weird at month end.
    Filter the birthdays for the existing month only here (I don't understand your birthday format)
     Filter(
                        colusers,
                        birthday <> "MM/DD",
                        !IsBlank(displayName)
                    ),
     
    which should produce a list of all the birthdays in the month. Sort the list on birth date, filter all dates less than the current date, then select the first 3

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 172 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 94

#2
mmbr1606 Profile Picture

mmbr1606 94 Super User 2025 Season 1

Overall leaderboard