I am trying to get the most recent row in my google sheets .
{
“nodes”: [
{
“parameters”: {
“documentId”: {
“__rl”: true,
“value”: “1LGQPpcvWvugmjSPO2JKcnDATDO4pJZsRBI46C1GCwfc”,
“mode”: “list”,
“cachedResultName”: “Money tracker”,
“cachedResultUrl”: “https://docs.google.com/spreadsheets/d/1LGQPpcvWvugmjSPO2JKcnDATDO4pJZsRBI46C1GCwfc/edit?usp=drivesdk ”
},
“sheetName”: {
“__rl”: true,
“value”: “gid=0”,
“mode”: “list”,
“cachedResultName”: “Sheet1”,
“cachedResultUrl”: “https://docs.google.com/spreadsheets/d/1LGQPpcvWvugmjSPO2JKcnDATDO4pJZsRBI46C1GCwfc/edit#gid=0 ”
},
“options”: {
“dataLocationOnSheet”: {
“values”: {
“rangeDefinition”: “detectAutomatically”
}
},
“outputFormatting”: {
“values”: {
“general”: “UNFORMATTED_VALUE”,
“date”: “FORMATTED_STRING”
}
}
}
},
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 4.6,
“position”: [
1248,
224
],
“id”: “9353a771-150d-4182-86ff-5f40ce42b2b5”,
“name”: “Get row(s) in sheet”,
“alwaysOutputData”: false,
“credentials”: {
“googleSheetsOAuth2Api”: {
“id”: “Z0pSty68agRdu7o0”,
“name”: “Google Sheets account”
}
}
}
],
“connections”: {
“Get row(s) in sheet”: {
“main”: [
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “c4206b01d6dceb12bbafefa9f90a83adb987e9324d9ef65dc386a494615366cd”
}
}
I have attached the node above. Basically the problem is that it is only getting row 2 which is below my headers. I need the most recent row of data / bottom or all of the rows and i can add code to extract the most recent one. Any help would be appreciated as i believe this is my last step to finishing my first workflow. Thanks.
Hi @Hameez_Yaser
Looks like you’re very close! Let’s try to fix your Google Sheets node so it returns ideally, just the last (most recent) row from the sheet.
Problem:
Try this
Use Get Row(s) without filters in yout node
Operation : Get Row(s)
Sheet Name : Sheet1
Filters : Leave completely empty
Options → Data Location on Sheet → Range Definition : Set to Detect Automatically
No “limit” or filters applied — n8n will fetch the full sheet contents (minus the header row).
That will give you all the data rows, not just row 2.
Then add a Function Node to Get the Last Row
Now that you’re receiving all rows, use this Function node to extract the most recent one:
// Return only the last item from the list of rows
const lastRow = items[items.length - 1];
return [lastRow];
Hi thanks for the help but it didnt work. I will attach my node below and my output. {
“nodes”: [
{
“parameters”: {
“documentId”: {
“__rl”: true,
“value”: “1LGQPpcvWvugmjSPO2JKcnDATDO4pJZsRBI46C1GCwfc”,
“mode”: “list”,
“cachedResultName”: “Money tracker”,
“cachedResultUrl”: “https://docs.google.com/spreadsheets/d/1LGQPpcvWvugmjSPO2JKcnDATDO4pJZsRBI46C1GCwfc/edit?usp=drivesdk ”
},
“sheetName”: {
“__rl”: true,
“value”: “gid=0”,
“mode”: “list”,
“cachedResultName”: “Sheet1”,
“cachedResultUrl”: “https://docs.google.com/spreadsheets/d/1LGQPpcvWvugmjSPO2JKcnDATDO4pJZsRBI46C1GCwfc/edit#gid=0 ”
},
“options”: {
“dataLocationOnSheet”: {
“values”: {
“rangeDefinition”: “detectAutomatically”
}
}
}
},
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 4.6,
“position”: [
432,
384
],
“id”: “1196e96c-2e65-41a5-8f46-f5649f254151”,
“name”: “Get row(s) in sheet1”,
“credentials”: {
“googleSheetsOAuth2Api”: {
“id”: “Z0pSty68agRdu7o0”,
“name”: “Google Sheets account”
}
}
}
],
“connections”: {},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “c4206b01d6dceb12bbafefa9f90a83adb987e9324d9ef65dc386a494615366cd”
}
}
Output:
row_number
2
Date
2025-07-28
Type
spent
Amount
10
Category
miscellaneous
Balance
610
As you can see it only gave the top row (excluding headers) and i believe i have set it exactly how you told me to.
Hi @Hameez_Yaser
It works well using the workflow I provided. Even if I configure it to retrieve the last 3 rows , it works.
See my basic sample workflow here if that helps.
1 Like
cheers mate, i must have been doing something wrong and everythings working now. Just finished my first proper workflow. Thanks again.
1 Like
system
Closed
August 5, 2025, 6:32pm
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.