Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
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?

 

  • Verified answer
    v-yetonggu-msft Profile Picture
    on at
    Re: Duplicate only rows sharepoint list with last date adn then update this date adding 1 day

    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow