Continuing the discussion from Automated Row Duplication Based on Integer Value In Column:
Hello! I’m a beginner here with coding skills that are so outdated, they might as well be hieroglyphics, but I’m looking to upgrade. I found what I thought might be a solution to my problem in the link above, but I’m getting an error message:
TypeError: cakeRecordIdsAndNames.map is not a function
What I actually need to do is slightly different than the original code intended, so I thought I’d reach out here to see if anyone can help.
Essentially, I have a data set that is linked to some current data by the variable name. The newly integrated data has individual years as fields with the relevant value whereas the original data had a field called year and another year called value. We need the latter. So we’re trying to transpose a portion of each record.
I’ll break it down into 2 parts, as I’m fairly certain Part 1 can be automated, but less confident about Part 2.
Part 1: Duplicate a record X number of times, where X is indicated in column # Count*
(If generating in a new table as per the original code is easier, that works too.)
*The number excludes any columns with Missing, so only indicates duplication where there is a value in the specific year field (e.g. “2018”). Please note that in the image below many of the columns are hidden, so the number you see in # Count is including those hidden years. There are 30+ years of historical data.
Part 2: Update the fields “year” and “value” based on information in the original record, i.e the specific year field with the specific value. See picture below.
Any chance this is possible? Would it be easier if the number of duplicated rows was equal to the # of fields so that Missing could also be accounted for? If so, it’s easy enough for us to update the Count field.