Reporting data from multiple sheets in Google Spreadsheets using one-to-many connections

I am facing a challenge in replicating a "one-to-many relationship" (similar to a database) from one sheet to another within the same spreadsheet.

Despite researching similar topics, I have not found a solution that fits my specific needs.

Basically, here is what I need to accomplish:

  • There is a sheet (PrimaryTable) where unique Elements are stored with a pkElementID column as the primary key, and
  • a separate sheet (SecondaryTable) where properties for each Element are stored, linked through an fkElementID column acting as a foreign key.

Additional details about this setup include:

  • The PrimaryTable has over 2000 rows, while the SecondaryTable is of similar size.
  • In the SecondaryTable, the properties for each element are spread across multiple columns but can be concatenated into one using an array formula.
  • The data from the secondary table consists of large strings of HTML text (~1000 characters or more) that need to be combined.
  • The formula should be an Array Formula so it automatically populates as new rows are added, preferably in a locked header cell in the first row.

An example scenario would involve storing URLs of multiple images per Element inside the HTML code (<img> tag) in corresponding cells of the PrimaryTable.

Previously, I found a solution on Ted Juch's blog which used a complex formula:

ArrayFormula(TRANSPOSE(SPLIT(CONCATENATE(REPT(TRANSPOSE('Secondary Table'!B1:B&", ");(A1:A=TRANSPOSE('Secondary Table'!A1:A))*(LEN(A1:A)>0))&REPT(CHAR(9)&" "&CHAR(9);TRANSPOSE(ROW('Secondary Table'!A1:A))=ROWS('Secondary Table'!A1:A)));", "&CHAR(9);0)))

Although I understood how it works, I struggle to maintain or modify it for different scenarios. It recently threw an "out of range" error, leaving me puzzled.

The only change I made was adding an "if (row(A1:A)=1;"Column Header"; FORMULA)" snippet within the initial formula:

ArrayFormula(IF(ROW(A1:A)=1;"Column Header"; TRANSPOSE(SPLIT(CONCATENATE(REPT(TRANSPOSE('Secondary Table'!B1:B&", ");(A1:A=TRANSPOSE('Secondary Table'!A1:A))*(LEN(A1:A)>0))&REPT(CHAR(9)&" "&CHAR(9);TRANSPOSE(ROW('Secondary Table'!A1:A))=ROWS('Secondary Table'!A1:A)));", "&CHAR(9);0))))

I suspect the issue may be due to the large dataset creating an oversized array beyond Google Spreadsheet limits, or perhaps I messed up the formula trying to adapt it.

I also attempted to create a custom function using the ArrayLib library, specifically the ArrayLib.filterByText function, but encountered a "Service timed out" error after processing only a few rows.

Should I consider using a query method instead? Any assistance would be greatly appreciated.

Answer №1

Check out this amazing solution I discovered (shoutout to Alexandra Ivanova)

Important to mention that the many-to-one relationship is stored in a non-standardized way, but it functions seamlessly and could serve as inspiration for a more comprehensive approach.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transforming JSON data into XML using Angular 7

It turns out the xml2js npm package I was using doesn't support converting JSON to XML, which is exactly what I need for my API that communicates with an application only accepting XML format. In my service file shipment.service.ts import { Injecta ...

Changing an object received as a prop in Vue.js

Is it acceptable to mutate values in a prop when passing an Object reference? In the process of developing a web application that involves passing numerous values to a component, I am exploring the most efficient method of handling value passing between c ...

Modify the css within a Bootbox dialog box

I am looking to enhance the appearance of the text "Hello world" in the following code snippet by applying some styling such as making it bold: bootbox.alert("Hello world!", function() { Example.show("Hello world callback"); }); Your help is greatly a ...

AJAX not returning any data as expected

Trying to Retrieve Data public function fetchTask($id){ $this->id = $id; $conn = $this->connect()->prepare("SELECT * FROM tasks WHERE id=:id"); $conn->bindParam('id', $this->id); $conn->execute(); $task = $c ...

It's impossible to remove a dynamically added class from a button

I'm facing an issue with adding and removing classes from a button using jQuery. I added a new class to the button, then removed it, but now when I click the button again I want to revert back to the initial class. Unfortunately, my code is not workin ...

Is there a way to prevent the React history.push from reloading the component every time? I only want

After loading a component and redirecting using history.push, my component renders twice, triggering the componentDidMount() function twice as well. Below is a simplified version of my component. Everything runs fine with componentDidMount() running only ...

Implementing Axios interceptor is a common practice in Vue.js applications to central

Hello everyone, I'm facing a problem with the interceptor in VueJS. I can't seem to figure out where the issue lies and it's driving me crazy... I've gone through various tutorials and read numerous posts on stackoverflow, but everythi ...

Exploring ReactJS Design Patterns: Comparing Class Components to Custom Components

As I delve into best practices and design patterns using React, I find myself pondering the choice between two similar solutions: The first solution involves a class that does not extend a component. Its constructor returns an element set based on an obje ...

Looking to dynamically modify the preselected rows in an Angular Slickgrid grid option when a button is clicked by calling a function (check)

When the button is clicked, certain specific rows are selected using a preselected grid option in Angular Slickgrid. However, if I do this, the preselected row in the grid options changes but it does not display properly. Please assist me. Typescript File ...

Using JQuery to update text input value with JSON response from AJAX call

I currently have an Autocompleter set up and working smoothly. Now, I am looking to implement an "Autofiller" feature. This means that when I select a company from the Autocompleter, it should retrieve all results from the database for that specific compan ...

What is the best way to protect sensitive database connection details before pushing to Github, while still ensuring they can be easily restored when needed

Currently, I am utilizing mongoose for database connection and have hardcoded the database details in my code. However, when sharing my code on GitHub, I need to remove this sensitive information. Is there a way to easily restore it when necessary? ...

Guide to redirecting a page using AngularJS

angular.module('myApp',[]) .controller('loginCtrl',function ($scope, $http, $rootScope, $location, $window{ $scope.login = function(loginData){ $scope.dataLoading = true; $scope.loginData = angular.copy(loginData); $http({ ...

Node.js tip: track down and address ignored errors in your code

Is there a method in node.js to track and log all exceptions? I find process.on('uncaughtException') insufficient for my needs, as I want to log all handled and unhandled exceptions, even if they were caught and disregarded using a catch block s ...

Unable to toggle visibility of div using Hide/Show function

I've noticed that the questions already posted do not solve my issue. I have a side menu bar displaying options and I want the content of the selected option to be displayed on the same page, while hiding the other div content. I have tried the follow ...

Tough Javascript/jQuery Animation (Spinner/Scroller)

I want to create a feature where clicking a button makes a div spin with randomized contents, eventually slowing down and stopping at a specific point. I'm not sure how to begin this process. For reference, here's an example of what I have in mi ...

Tips for extracting information from a concealed HTML field with jQuery

I am facing a challenge in extracting the value from a hidden field using jQuery. Below is my code snippet where I hide a certain value: (...)$.each(response, function (index, value) { $('#notiContent').append( $('<li>N ...

Unable to show the same error message in multiple locations using identical code

I am facing an issue where error messages are not displaying for an empty input field, while they work perfectly fine for a textarea. The if statement for the inputName seems to be working, but the else statement is not being triggered. What could be causi ...

Create a list using ng-repeat in AngularJS, each item separated by "custom categories"

I am looking to create a dynamic list that will display values entered by users, categorized by custom categories. The challenge is that I do not know in advance which category each element will belong to. Here's an example of how I envision the list ...

I'm facing a frustrating issue where using NodeJS with the Passport local strategy is resulting

I am experiencing a severe headache when attempting to log in using Passport. When I make a post request to /login with an email and password, Passport successfully authenticates it without any errors. However, the return res.redirect('/user') fu ...

Chrome and Firefox provide excellent compatibility for running JavaScript, whereas Safari may encounter some issues. Opera's performance with JavaScript can be quirky

Disclaimer: I'm new to web design and development. I have encountered an issue with posting information from a form built on CodeIgniter using jQuery. The form posts successfully in Chrome and Firefox, with the current page automatically reloading. H ...