问题
I have a table where if a row is missing it means the value for that row is zero.
so for
2020-10-12 label L2 has all 0 values for all display url.
2020-10-12 label L3 has all 0 values for all display url except d2.
How can I fill this missing data in the pivot table?
I want the graph to be analog and not discreet for each series.
My unsuccessful try:
回答1:
Explanation:
You can fill in with zeros the empty cells of the raw data and as a result the pivot table will contain zeros instead of empty cells.
In the following script, select the sheet name where the raw data is located and choose the exact data range where you want to check for empty cells.
The script will get all the values of the selected range and it will add zeros to the empty cells. You can use map() to accomplish this operation:
const data=range.getValues().map(row=>row.map(r=>r==''? 0:r));
Solution:
Adjust Sheet1 and A1:I20 to your particular case:
function myFunction() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Sheet1'); // select the name of the Sheet
const cords = 'A1:I20'; // select the range you want to paste zeros
const range = sh.getRange(cords);
const data=range.getValues().map(row=>row.map(r=>r==''? 0:r));
range.setValues(data);
}
来源:https://stackoverflow.com/questions/64449734/how-to-fill-with-zeros-empty-or-missing-cells-in-a-google-sheets-pivot-table