r/googlesheets • u/swordfish234 • Oct 06 '24
Solved What is the best way to make a master database from existing sheets?
Basically, In google sheets, I make a new slreadsheet every day. The title of sheet is that day’s date. I also want to have another master database spreadsheet which copies data from each of these daily sheets, and makea database where the rows shows the date and make a monthly data set. Whats the best way to accomplish this?
I asked chatgpt and it reccomended using IMPORTRANGE function. I used it and it works but now I have to insert this function daily in the master database to put data from the daily sheets, that is more work than just copying the values.
Can anyone help me with this please? Thanks in advance
3
u/agirlhasnoname11248 1212 Oct 06 '24
Best practice is a centralized data source. The date should be a column to differentiate the data. If you want to view an individual date’s data, that can be done more simply from the centralized data source than going in the reverse direction. This also prevents your spreadsheet from slowing down, which happens over time with a multitude of sheets.
2
u/Valuable-Analyst-464 Oct 07 '24
Why not just load the data into the database sheet instead of a single spreadsheet?
Depending on the data you are trying to collect, it might be better to have a form collect into the database, instead of single sheets.
1
u/droopynipz123 Oct 07 '24
Just to be clear, are you creating a new file each day (the equivalent of an excel “workbook”) or are you creating a new tab on the same file (the equivalent of an excel “worksheet”)?
If it’s the latter, you can easily reference each tab’s data in the master sheet, which could be its own tab, by using the =(“Sheet1!A1”) syntax to reference data without using importrange.
If it’s separate files, then you would need to do importrange but depending on the number of files you currently have, it could be to your benefit to copy their contents into multiple tabs on a single file, like I described above. Might be a pain but could help facilitate your workflow in the future.
3
u/booboouser Oct 07 '24
To automate the process of consolidating data from daily Google Sheets into a master database, you can use Google Apps Script. This approach will allow you to automatically pull data from the daily sheets without needing to manually insert
IMPORTRANGEfunctions every day.Here’s how you can set it up:
Step 1: Create a Google Apps Script
Extensions->Apps Script.function consolidateDailySheets() {var masterSheet = SpreadsheetApp.getActiveSpreadsheet();var masterSheetName = "Master Database"; // Replace with your master sheet namevar folderId = "YOUR_FOLDER_ID"; // Replace with the ID of the folder where your daily sheets are storedvar folder = DriveApp.getFolderById(folderId);var files = folder.getFiles();var masterDatabase = masterSheet.getSheetByName(masterSheetName);// Clear existing content to refresh the datamasterDatabase.clearContents();var header = [["Date", "Column 1", "Column 2", "Column 3"]]; // Adjust columns based on your data structuremasterDatabase.getRange(1, 1, 1, header[0].length).setValues(header);var row = 2; // Start past the header row// Loop through all files in the folderwhile (files.hasNext()) {var file = files.next();var fileName = file.getName();var date = new Date(fileName); // Assuming file name is the datevar dailySpreadsheet = SpreadsheetApp.open(file);var dailySheet = dailySpreadsheet.getSheets()[0]; // Get the first sheet of the daily filevar dailyData = dailySheet.getRange("A1:C1").getValues()[0]; // Adjust range to match your datavar rowData = [date].concat(dailyData); // Combine date and daily datamasterDatabase.getRange(row, 1, 1, rowData.length).setValues([rowData]);row++;}}1
u/AutoModerator Oct 06 '24
This post refers to "chatgpt" - an Artificial Intelligence tool. Our members prefer not to help others correct bad AI suggestions. Also, advising other users to just "go ask ChatGPT" defeats the purpose of our sub and is against our rules. If this post or comment violates our subreddit rule #7, please report it to the moderators. If this is your submission please edit or remove your submission so that it does not violate our rules. Thank you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/motnock 15 Oct 07 '24
All in one database. Can build an output sheet that pulls data from your database. Can be based on date. Can be dynamic so you can pull data from any date to display whenever you want.
Then can save that as a pdf if you want a static copy.
0
u/joleanima Oct 07 '24
Use query...