cancel
Showing results for
Did you mean:
Highlighted
Anonymous
Not applicable

## Filtering Flow

Hi there,

I am in the middle of creating a flow that extracts data from a SP list, this in itself is relatively easy.

However, I would now like to filter what data it extracts based on the date this was added, meaning  if it was added whithin a specific periode it should be extracted to one place, if it was added in a different period it should extract it to a different place.

Eg. all data added to the SP list between the 21st and the 20th of two months should go to X location, and then a new period should start with the 21st to the 20th of the next months? so essentially create a "period" filter based on dates

Hope this makes sense, thanks in advance

- Tobi

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II

## Re: Filtering Flow

Hey @Anonymous

Sure it's possible.

Here's the flow:

Regarding the formulas, let's get the 20th of last month. The first instinct is to get the number of the month and reduce it by one, but then you can run into issues (timezones, leap years, etc.). The best way to do this is to get the last month (using the formula for that), get the first day and add X days. Then you're always sure that you're calculating the correct date. With this in mind, here are the two formulas:

`addDays(startOfMonth(subtractFromTime(utcNow(),1,'Month')),20)`

and

`addDays(startOfMonth(utcNow()),19)`

Now it's just a question of comparing them and proceed with your flow.

If you like my response, please give it a Thumbs Up.

Cheers
Manuel

10 REPLIES 10
Highlighted
Super User II

## Re: Filtering Flow

Hi @Anonymous

I think the easiest way is to do the following:

1. Define the period(s) first. Is it easy to calculate it?
2. Use a "case" to filter based on the periods.
3. Do the actions that you need.

Here's a skeleton so that you understand what I mean.

The advantages of using the "compose" is that you can convert the data and always be sure you're calculating the period correctly. After that, use the cases to filter to each of your periods.

Cheers!

If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Highlighted
Community Support

## Re: Filtering Flow

Hi @Anonymous ,

You should create flow as below:

And please create a "period" in the Condition then do something you want.

Best regards,

Alice

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Anonymous
Not applicable

## Re: Filtering Flow

@manuelstgomes

I will definately try this out, I'll let you know if this fixes the issue 🙂

- Cheers

Highlighted
Anonymous
Not applicable

## Re: Filtering Flow

@v-alzhan-msft

Hi Alice, Surely in this case i would have to manually add every single period, instead of being able to calculate the periods using a formulae of sorts, or is it because you have experience with this, and know that this works and the other method won't 🙂

- Tobi

Highlighted
Super User II

## Re: Filtering Flow

@Anonymous awesome!

If you need help along the way or get stuck just let me know.

If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Highlighted
Anonymous
Not applicable

## Re: Filtering Flow

@manuelstgomes  Perfect thanks, I will do 🙂

Highlighted
Anonymous
Not applicable

## Re: Filtering Flow

@manuelstgomes I am working away.

However, i'm finding myself getting stuck when writing the equation.

Essentially i am trying to say: Check if the date is between the 21st of last month and the 20th of this month; If yes, Return true and complete action, if not, Exit 🙂

But I just can't seem to get this right, if it is even possible 🙂

Highlighted
Super User II

## Re: Filtering Flow

Hey @Anonymous

Sure it's possible.

Here's the flow:

Regarding the formulas, let's get the 20th of last month. The first instinct is to get the number of the month and reduce it by one, but then you can run into issues (timezones, leap years, etc.). The best way to do this is to get the last month (using the formula for that), get the first day and add X days. Then you're always sure that you're calculating the correct date. With this in mind, here are the two formulas:

`addDays(startOfMonth(subtractFromTime(utcNow(),1,'Month')),20)`

and

`addDays(startOfMonth(utcNow()),19)`

Now it's just a question of comparing them and proceed with your flow.

If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Highlighted
Anonymous
Not applicable

## Re: Filtering Flow

@manuelstgomes

It works, praise the heavens.

Had to work it a little bit as i was not the most consistent, but it works!

Thank so much 🙂

Highlighted
Super User II

## Re: Filtering Flow

Awesome!!!!! Well done!

If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Announcements

#### Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

#### Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

#### Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Top Solution Authors
Top Kudoed Authors
Users online (9,610)