cancel
Showing results for
Did you mean:
Anonymous
Not applicable

## Filter with IF statement

Hi Guys,

As you below can see I have 2 different galleries. Gallery 1 must show the data of next month, and gallery 2 must show the month after next month in this case January 2020.

The first gallery show the exact data. This the formula that I use.

Spoiler
Filter('[dbo].[Kopie van operationeel]', Year(Period) = Year(Today()) && Month(Period) = Month(DateAdd(Today(), 1, Months)))

You feel the question coming how do I have to do for Gallery 2. because when I use  2, Months)) in stead  of1 then I see January 2019 in stead of January 2020.

I can put 1 + year like I did for month but this is not the solution because it is not dynamic.

Period is date column in my SQL table.

1 ACCEPTED SOLUTION

Accepted Solutions
Responsive Resident

Hi @Anonymous,

If I understand this correctly, the issue is the statement 'Year(Period) = Year(Today())', not the months. The reason is that the first half of your conditional and statement is searching for This Year, when it should be matching the year of the date 1 (or 2) months from today. Does this make sense?

Filter('[dbo].[Kopie van operationeel]', Year(Period) = Year(DateAdd(Today(), 1, Months)) && Month(Period) = Month(DateAdd(Today(), 1, Months)))

And the Gallery2 formula to read:

Filter('[dbo].[Kopie van operationeel]', Year(Period) = Year(DateAdd(Today(), 2, Months)) && Month(Period) = Month(DateAdd(Today(), 2, Months)))

2 REPLIES 2
Responsive Resident

Hi @Anonymous,

If I understand this correctly, the issue is the statement 'Year(Period) = Year(Today())', not the months. The reason is that the first half of your conditional and statement is searching for This Year, when it should be matching the year of the date 1 (or 2) months from today. Does this make sense?

Filter('[dbo].[Kopie van operationeel]', Year(Period) = Year(DateAdd(Today(), 1, Months)) && Month(Period) = Month(DateAdd(Today(), 1, Months)))

And the Gallery2 formula to read:

Filter('[dbo].[Kopie van operationeel]', Year(Period) = Year(DateAdd(Today(), 2, Months)) && Month(Period) = Month(DateAdd(Today(), 2, Months)))

Anonymous
Not applicable

Hi @chrisog

Perfect thanks!

Announcements

#### Celebrating the May Super User of the Month: Laurens Martens

@LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!

#### Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!