cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
livingstonep Kudo Collector
Kudo Collector

How to filter items in SP List and count result?

We have an SP List called eBayIT_TrackMySales and in our flow we need to get a count of items in the list that match the trigger record on two columns called T-Code and BoxNo

 

I guess I need to do a GetItems step and filter but I don't know where to go from there?

 

How can I do that please?

1 ACCEPTED SOLUTION

Accepted Solutions
livingstonep Kudo Collector
Kudo Collector

Re: How to filter items in SP List and count result?

in the end I resolved this by using quotes correctly in the filter:

BoxNo eq '@{triggerBody()['BoxNo']}' and T_x002d_Code eq '@{triggerBody()['T_x002d_Code']}'

and to get the count I used

length(body('Get_Items')['Value'])

it now works fine...

View solution in original post

8 REPLIES 8
Super User
Super User

Re: How to filter items in SP List and count result?

HI @livingstonep,

 

You can use the filter option in the Get items . For more details pleasee see my post on filtering on the get items action.

 

Once you get an array of items back. you can use the length function to count the items.

 

 

 

 

 

 

 

WDRC Helper V
Helper V

Re: How to filter items in SP List and count result?

Pieter @Pieter_Veenstra

So your example stated for dates "Created gt ‘2018-11-28'".  If I have colum called "Current Contact Date" and want to filter by only items in the last seven days including the current date I would need the "Current Contact Date lt addDays(utcnow(),-7,'Current_x0020_Contact-x0020_Date') I have a live example I need to get working by this time next week so I can send something out with data from today through to the 15/01/2019.

Regards,

 

Andrew 

Community Support
Community Support

Re: How to filter items in SP List and count result?

Hi @livingstonep,

 

What is the type of T-Code and BoxNo column in your sharepoint list?

 

Bet regards,

Alice

livingstonep Kudo Collector
Kudo Collector

Re: How to filter items in SP List and count result?

hi, T-Code is a string BoxNo is numeric (integer) We keep getting an error when filtering the GetItems ... thanks
livingstonep Kudo Collector
Kudo Collector

Re: How to filter items in SP List and count result?

 

in the Get-Items step we're trying to filter on two columns, BoxNo (integer) and T-Code (string)

 

so the GetItems step will find all records from the list where the T-Code and BoxNo in the list match the T-Code and BoxNo of the current record that triggered the flow...

 

here is what we've tried:

GetItems Filtering.PNG

(T-Code column has internal name T_x002d_Code)

 

then we need to run an Apply to each for all records matched,, and set a field called LabelSent to "Yes"

 

but when we test the flow we get an error:

The expression \"BoxNo eq 5 && T_x002d_Code eq A02\" is not valid.\r\nclientRequestId: 4b983a8c-7ba5-4a5f-8702-7ed96c564723\r\nserviceRequestId: f697b49e-c0e0-7000-7d75-d83eaa4973de"

Super User
Super User

Re: How to filter items in SP List and count result?

There seems to be a problem with quotes

Also I would set a variable to the date -7 rather than trying to resolve all in one expression
Then finally use the ticks function to compare dates rather than date fields directly
livingstonep Kudo Collector
Kudo Collector

Re: How to filter items in SP List and count result?

in the end I resolved this by using quotes correctly in the filter:

BoxNo eq '@{triggerBody()['BoxNo']}' and T_x002d_Code eq '@{triggerBody()['T_x002d_Code']}'

and to get the count I used

length(body('Get_Items')['Value'])

it now works fine...

View solution in original post

leonardoromano
New Member

Re: How to filter items in SP List and count result?

hi can you explain where did you put this?

and to get the count I used

length(body('Get_Items')['Value'])

thank you 

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Users online (7,557)