Hello,
I'm currently working on a PowerAutomate solution that in theory would take a SharePoint list, pull out the unique fields and then find the minimum date that is associated with that unique field.
Into the sausage making:
I have a column within a SharePoint list called "Project Group", and I have multiple items that can be part of that particular project group. The unique concern is there can be multiple dates associated with a single "Project Group", but I only am concerned with capturing the minimum date and writing that value to a different column in a SP list.
Through a Union, I can pull the unique "project groups", but I'm stuck on how to then get the minimum dates associated with that particular project group.
Any help on next steps would be greatly appreciated!
hi @Skiroy you can use get Item and use more options to add a Filter so you can add the ID from dynamic content from your firts get items action.
Proud to be a Flownaut!
Hello @Skiroy ,
since you already have the unique project groups, I'd loop through the project groups and for each used 'Get items' action that would:
The screenshot below is just an example, you should adjust the Filter Query and Order By fields according to the list
Hey Tom,
These things are always difficult to explain in full detail.
So the initial SP list has about 700 items, which have about 40 or 50 unique project groups, and ultimately I have another column in the initial SP list that will house the lowest date for each unique project group via update item.
The compose union gives me the list of 40 unique project groups, but I'm not sure what to put in the filter query in the second "get items" '[unique project group]' as the unique project groups are housed in the union array.
Hello @Skiroy ,
you have the project groups stored in the array, so to process them one by one you will use 'Apply to each' action. Inside this 'Apply to each' you'll use the 'Get items' action with the filter. The [unique project group] part of the filter is the current item (project group in your case) processed by the 'Apply to each' loop, it's represented by the dynamic content 'Current item'.
Example: if you've got an array [ "project_group1", "project_group2",...], and you use that array as an input of 'Apply to each' with the Filter Query: ProjectGroup eq 'Current item'.
But remember to use the internal name of the Project Group column in the filter.
Hey @tom_riha ,
Thanks for the break down of using current item in the second 'get items' filter query.
For some reason when I run the get items it's doing the compare / filter on the created category name from the select function and the actual value.
Looks something like:
Project_x0020_Group eq '{"ProjectGroup":"Q1 2019"}'
and of course I get a null value as an output because the project group is not called "ProjectGroup":"Q1 2019"
I guess the question, and it's probably a dumb one is how to reference the actual value (i.e., 'Q1 2019') from the output of the compose function above. Instead of just the current item which is "items('Apply_to_each')" , I tried to reference items('Apply_to_each')?['ProjectGroup/Value'] that didn't work either.
I believe we're close.
Hello @Skiroy ,
if you remove the /Value part from the reference it should work, the data is directly in the "ProjectGroup" key.
items('Apply_to_each')?['ProjectGroup']
Hey @tom_riha ,
For some reason it wasn't working before, but now it's running and pulling 59 unique project groups, with an associated earliest date (for most of them). The only one that isn't populating correctly is the first project group I have (earliest date is 1/4/2019, but for some reason it's picking up the second earliest date of 1/11/2019, not sure what's going on there, but anyways.
So we now have our list of unique project groups, and an output from the second get items 2 that has the associated lowest date.
How would we go about looping through all 700 records, where if the project groups match, then update item (different column within the same sharepoint list), with the lowest date associated with that project group. (honestly that is just a stop gap, the ideal solution would have it calculate -120 days from that lowest date, and that would be the value in the different column within the same sharepoint.
one step at a time!
Hello @Skiroy ,
once you get the lowest date, store it in some variable (to avoid unnecessary 'Apply to each' when using that date, you can also subtract the 120 days when setting the variable with the addDays(...) expression). Then repeat the 'Get items' step with the same filter, but this time without the limit on number of items. That will give you all items for given project, and you can loop through them and update each of them with the new date (from the variable).
This part of the flow would go like this:
User | Count |
---|---|
90 | |
44 | |
21 | |
18 | |
16 |
User | Count |
---|---|
133 | |
49 | |
42 | |
36 | |
28 |