Quick Start Kit: Automatically Keep a Daily History of Your Data
With the release of version v1.1 of the DataCollection module, we’re introducing a powerful new feature:

✅ Automatic daily data history backup.
This update helps ensure your dashboard data is archived every day, without manual effort. It’s a simple yet essential step to track progress, troubleshoot issues, or just maintain historical records for future reference.
Saving today's data allows you to build a historical record and track the evolution of all data over time, which can then be displayed in the Dashboard (lookerstudio).

1. How It Works
At the end of each day, a script automatically copies all data rows from the current day in the data_dashboard sheet and appends them to the bottom of the same file. This creates a growing historical record of your data over time — one snapshot per day.

2. How to Set It Up
You only need to schedule the script to run daily. Here’s how:
Open your Google Sheet.
Go to Extensions > Apps Script.
In the Apps Script editor, go to Triggers from the left-side menu.
Click on "Add Trigger" (bottom right).
Choose the function: copyTodayRowsUniqueAppli.
Set the event source to Time-driven.
Set the type to Daily.
Choose the time range: Between 11:00 PM and midnight.
Click Save.
Once this trigger is created, the function will run every day, backing up the day’s data automatically.
QE score - trigger QE score - trigger QE score - trigger QE score - trigger
3. If You’re Using an Older Version of the Quick Start Kit
If your DataCollection sheet doesn't include this feature yet:
Go to Extensions > Apps Script.
In the Apps Script editor, click the "+" icon to add a new script file.
Copy and paste the script below into the file.
Click Save.
Then follow the setup steps in section 2 to schedule the trigger.

function copyTodayRowsUniqueAppli() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("data_dashboard");
const today = new Date();
today.setHours(0, 0, 0, 0); // Normalize for comparison
const lastRow = sheet.getLastRow();
const lastCol = sheet.getLastColumn();
const allData = sheet.getRange(2, 1, lastRow - 1, lastCol).getValues(); // Full data from row 2
const matchingRows = [];
for (let i = 0; i < allData.length; i++) {
const row = allData[i];
const dateCell = row[0];
const colBValue = row[1];
if (!dateCell) break; // Stop at first empty date
const rowDate = new Date(dateCell);
rowDate.setHours(0, 0, 0, 0);
if (rowDate.getTime() === today.getTime()) {
// Count how many times this (today's date + col B) combo exists in the entire data
let count = 0;
for (let j = 0; j < allData.length; j++) {
const d = new Date(allData[j][0]);
d.setHours(0, 0, 0, 0);
if (d.getTime() === today.getTime() && allData[j][1] === colBValue) {
count++;
}
}
if (count <= 1) { // Only copy if the combo exists once or less
matchingRows.push(row);
}
}
}
if (matchingRows.length > 0) {
const destinationStartRow = sheet.getLastRow() + 1;
sheet.getRange(destinationStartRow, 1, matchingRows.length, matchingRows[0].length)
.setValues(matchingRows);
Logger.log(matchingRows.length + " row(s) copied.");
} else {
Logger.log("No rows to copy: all (date + column B) combos already exist more than once.");
}
}
This simple setup ensures you always have a reliable history of your data — versioned by day — with no manual exports
or archiving needed.Ready to try it? Upgrade to v1.1 and set up your trigger today!


Comments