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 Platform Community / Forums / Power Automate / Duplicate only rows sh...
Power Automate
Answered

Duplicate only rows sharepoint list with last date adn then update this date adding 1 day

(0) ShareShare
ReportReport
Posted on by

Hi all,

I need assistance with this, i am importing data from a SharePoint list like this:

 

NEZAL_0-1710026597996.png

 

Here i have DATE, Well(uniqueID in each date), Responable, Petroleo and Agua.

 

As you can see there are plenty of items by date, i am trying to make a flow with PowerAutomate which look up for all elements at the last date, then duplicate and finally update that date addind one day. So after the flow, i wish to have this:

 

NEZAL_1-1710026970777.png

 

As you can see, only was duplicated the items that are in the last date in the list( orange box to green box) and then this date was update adding 1 day more.

 

I try to create a flow like this:

 

NEZAL_2-1710027199148.png

 

1.- First get the items:

 

NEZAL_3-1710027246267.png

2.- Then i define an If condition, where just select the items that have the last date in the list:

NEZAL_7-1710027653365.png

 

 

3. If true, it creates that item, duplicate all values in rows but change the date adding 1 day and added to the same sharepoint list.

NEZAL_5-1710027391127.png

 

These is the code:

{
  "type": "Foreach",
  "foreach": "@outputs('Get_items')?['body/value']",
  "actions": {
    "Condition": {
      "type": "If",
      "expression": {
        "and": [
          {
            "greaterOrEquals": [
              "@items('For_each')?['DATE']",
              "@last(items('For_each')?['DATE'])"
            ]
          }
        ]
      },
      "actions": {
        "Create_item": {
          "type": "OpenApiConnection",
          "inputs": {
            "parameters": {
              "dataset": "https://netorgft4694131.sharepoint.com/sites/PRD-APP",
              "table": "afa40198-3621-44a2-afaa-3e76040d490f",
              "item/DATE": "@{addDays(items('For_each')?['DATE'],1,'Day')}",
              "item/WELL": "@items('For_each')?['WELL']",
              "item/Petroleo_x0028_bopd_x0029_": "@items('For_each')?['Petroleo_x0028_bopd_x0029_']",
              "item/Agua_x0028_bwpd_x0029_": "@items('For_each')?['Agua_x0028_bwpd_x0029_']",
              "item/Gas_x0028_Mpcd_x0029_": "@items('For_each')?['Gas_x0028_Mpcd_x0029_']",
              "item/Ptubos_min_x0028_psi_x0029_": "@items('For_each')?['Ptubos_min_x0028_psi_x0029_']",
              "item/Ptubos_max_x0028_psi_x0029_": "@items('For_each')?['Ptubos_max_x0028_psi_x0029_']",
              "item/Pcasing_min_x0028_psi_x0029_": "@items('For_each')?['Ptubos_min_x0028_psi_x0029_']",
              "item/Pcasing_max_x0028_psi_x0029_": "@items('For_each')?['Ptubos_max_x0028_psi_x0029_']",
              "item/Plinea_x0028_psi_x0029_": "@items('For_each')?['Plinea_x0028_psi_x0029_']",
              "item/Psep_x0028_psi_x0029_": "@items('For_each')?['Psep_x0028_psi_x0029_']",
              "item/Timeron_hrs": "@items('For_each')?['Timeron_hrs']",
              "item/Timeroff_hrs": "@items('For_each')?['Timeroff_hrs']",
              "item/Beam_64": "@items('For_each')?['Beam_64']",
              "item/Presion_AB_x0028_psi_x0029_": "@items('For_each')?['Presion_AB_x0028_psi_x0029_']",
              "item/Presion_DB_x0028_psi_x0029_": "@items('For_each')?['Presion_DB_x0028_psi_x0029_']",
              "item/Carrera": "@items('For_each')?['Carrera']",
              "item/SPM": "@items('For_each')?['SPM']"
            },
            "host": {
              "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
              "connection": "shared_sharepointonline",
              "operationId": "PostItem"
            }
          }
        }
      },
      "else": {
        "actions": {}
      }
    }
  },
  "runAfter": {
    "Get_items": [
      "Succeeded"
    ]
  }
}

 

These is the result:

NEZAL_6-1710027560964.png

 

I get no result, i think that i am defining in bad way tha max date. Can you help me?

 

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

    Hi @NEZ-AL ,

    My SharePoint List Before:

    vyetonggumsft_1-1710211741377.png

    My SharePoint List After:

    vyetonggumsft_2-1710211780024.png

    I did a test for your reference.

    In my scenario:

    Please switch to classic designer.

    vyetonggumsft_3-1710065045409.png

    My Flow:

    vyetonggumsft_0-1710064675410.png

    Please use the sort function to sort the Date column of the items in Get items from small to large, and last gets the largest date.

    Filter out items whose Date is equal to the maximum date in the Filter array, update the dates of the filtered items, and use the AddDays function to add one day to the maximum date.

    vyetonggumsft_1-1710064877471.png

     

    last(sort(outputs('Get_items')?['body/value'],'Date'))['Date']
    items('Apply_to_each')?['Id']
    items('Apply_to_each')?['Title']
    AddDays(items('Apply_to_each')?['Date'],1,'yyyy-MM-dd')

     

    Best Regards,

    Sunshine Gu

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 253 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 172 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 134 Super User 2026 Season 2

Last 30 days Overall leaderboard