web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

max values in group

(0) ShareShare
ReportReport
Posted on by 12

Hi, I would like to create the flow and send an email notification, getting data from SharePoint. table looks like this.

Id Country          code   values  dates                reporter

1  Portugal          1          1        30/02/2020      mouse

2  Portugal          1          2        30/03/2020      mouse

3  Sweden           2          1        30/05/2020      ninia

 

so if Country and code are the same, I want to group and find max number in values column and check if dates are greater than 90 days from current day., and I would like to send email to reporter. so in this case, id 2, and id 3 need to be sent to reporter.

 

does anyone can put me on the right track?

Any feedbacks are welcome.

Thank you

 

 

 

Categories:
I have the same question (0)
  • v-litu-msft Profile Picture
    Microsoft Employee on at

    Hi @leopold1,

     

    According to your description, I create a Flow as below, you could following these steps to approach that:

    1. Get items without any filter query, and initialize an array variable;

    2. Create a loop, append the county and code key-values into the variable;

     

    {
    "Country": @{items('Apply_to_each')?['Country']},
    "code": @{items('Apply_to_each')?['code']}
    }

     

    3. Use union() function to remove repeat item;

    4. Put its output of Steps 4 into a loop, then create second Get items action with filter query, and Order by set to "desc" and top count value to "1":

    Country eq '@{item()?['Country']}' and code eq '@{item()?['code']}'

    5. Get the first member of return, and compare its dates with the utc time - 90 days:

    outputs('Get_items_2')?['body/value'][0]['dates']
    addDays(utcNow(),-90)

    If its dates less than 90 days ago, send email to reporter.

    Screenshot 2021-04-20 104709.jpg

     

    Screenshot 2021-04-20 105606.jpg

     

    Screenshot 2021-04-20 105649.jpg

     

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

  • leopold1 Profile Picture
    12 on at

    Hi  @v-litu-msft 

     

  • v-litu-msft Profile Picture
    Microsoft Employee on at

    Hi @leopold1,

     

    I guess you may be lost step 3 to remove duplicated records.

    Could you please confirm this point?

     

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

  • leopold1 Profile Picture
    12 on at

    Hi I used the Union() as it was described but still get dublicate emails.

    leopold1_1-1619537080383.png

     

    Also my dates in orginal file is YYYY-MM-DD can be this reason?

     

  • abm abm Profile Picture
    32,985 Most Valuable Professional on at

    Hi @leopold1 

     

    There is another way to determine this but this requires some schema changes. Add a new column called highervalue or select as Yes/No. Then whenever a record gets inserted in a list run a flow to find whether the ID and country already exists. If no record exists set the new field as Yes. If already exists then check the value Vs the new value then update the relevant record column to Yes. Next when you run the report all you need to do is filter the record by new field value as 'Yes'.

     

    Thanks

  • leopold1 Profile Picture
    12 on at

    Hello @abm thank you vey much. I got stuck in this step:

    "If already exists then check the value Vs the new value then update the relevant record column to Yes." Could you please help me here?

    Also, what will happened to old "yes" column when new item will be created? For example:

    Id Country          code   values  dates                reporter highervalue

    2  Portugal          1          2        30/03/2020      mouse    Yes

     

    next time when user will add Id 3: Portugal and code will be checked and in highervalue  it will be assigned yes.

    3  Portugal          1          3        30/05/2020      mouse    Yes                                                                                               

    But id 2 will be kept with highervalue yes .

     

    Thank you in advance.

     

  • abm abm Profile Picture
    32,985 Most Valuable Professional on at

    Hi @leopold1 

     

    The old value you need to update as 'No'.

  • leopold1 Profile Picture
    12 on at

    Hi @abm in theory i know, but I could not build a flow. any more detailed tips? I am a fresh user and all feedback will be valuable. thank you.

  • abm abm Profile Picture
    32,985 Most Valuable Professional on at

    Hi @leopold1 

     

    Here it is.

     

    image.png

    image.png

    image.png

    image.png

     

  • leopold1 Profile Picture
    12 on at

    hi @abm , thank you for the flow.  I tested,  flow runs successfully but it is not updated anything in highervalue column.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard