ImportJSON icon indicating copy to clipboard operation
ImportJSON copied to clipboard

In Google Sheets Pivot Tables Calculated Fields formulas had problems

Open frafor opened this issue 3 years ago • 0 comments

If !rawHeaders is set, then I modified this:

function defaultTransform_(data, row, column, options) {
      if (data[row][column] == null) {
        if (row < 2 || hasOption_(options, "noInherit")) {
          data[row][column] = "";
        } else {
          data[row][column] = data[row-1][column];
        }
      } 
    
      if (!hasOption_(options, "rawHeaders") && row == 0) {
        if (column == 0 && data[row].length > 1) {
          removeCommonPrefixes_(data, row);  
        }
        
        **data[row][column] = toTitleCase_(data[row][column].toString().replace(/[\/\_]/g, ""));**
      }
      
      if (!hasOption_(options, "noTruncate") && data[row][column]) {
        data[row][column] = data[row][column].toString().substr(0, 256);
      }
    
      if (hasOption_(options, "debugLocation")) {
        data[row][column] = "[" + row + "," + column + "]" + data[row][column];
      }
    }
    **data[row][column] = toTitleCase_(data[row][column].toString().replace(/[\/\_]/g, ""));**

It was .../g, " ", a space; it is now an EMPTY STRING.

When using the original data as the source of a Pivot Table, the Calculated Field formula would not work because of the SPACE at the beginning of all columns' names.

In the case of the column names of rawHeaders set, then I get all column names prefixed with '/', which make it impossible to use the column names in formulas for calculated fields.

I have not tried to fix the above so that the '/' prefix character is not included.

It would be nice to fix both things.

Thanks.

frafor avatar Feb 26 '21 00:02 frafor