Forum Discussion

amalts0101's avatar
amalts0101
Data Storage
09-06-2023
Solved

How to add a single row below the header in pivot widget.

Hi,

I was working with the pivot widget in my dashboard and I needed to add a row right below the header like a description.It should be above the table content which should appear right below the header and it should be shown in the export as well. I tried using JS also but I couldn't get it to work. I have attached an image below for reference. Any help is much appreciated.

Thank you.

  • Hi amalts0101

    The following script can be applied to Pivot widgets to convert cell contents of the row below the header, but does not create / add an entirety new row to the table itself, only edit an existing one: 

    // Customize the text of the row after the header of a pivot table
    widget.transformPivot({
        type: ['member', 'subtotal', 'value']
    }, transformPivotFunction);
    function transformPivotFunction(metadata, cell) {
        // Change text of array to number of columns
        customText = ["Custom", "Text", "Here", "As", "Long", "As", "Needed"]
        if (metadata.rowIndex == 1) { //only change text content for first row
            // Convert cell content to new text
            cell.content = customText[metadata.colIndex];
            cell.text = customText[metadata.colIndex];
        }
    }

    Note that  Pivot scripts can be applied only to tables in the web application and can not target widgets on export, so the script will indeed allow dashboard designers to hard code a header description in row 1 of the Pivot in the Sisense web application, but unfortunately this will not meet the requirement of that row being displayed on export. If you are interested in enhancing / supplementing this script to incorporate additional requirements, please reach out to your Customer Success Manager who can loop in our Field Engineering Services team for discovery of further development. 

    Alternatively, if a data dictionary is ultimately what you are looking to accomplish here - a text box can be added to your dashboard above / below / to the side of your Pivot table providing a description / formula for each KPI, with the added benefit of working seamlessly on export. 

    Furthermore, adding tooltips to a Pivot table is possible using instructions in the Community article here, although again will face the same limitation of only being applicable to the web application, and will not target exports. 

    Hope this helps but please let us know if any additional questions come up or if any clarification is needed and we will be happy to help. 

1 Reply

Replies have been turned off for this discussion
  • mreich's avatar
    mreich
    Sisense Employee

    Hi amalts0101

    The following script can be applied to Pivot widgets to convert cell contents of the row below the header, but does not create / add an entirety new row to the table itself, only edit an existing one: 

    // Customize the text of the row after the header of a pivot table
    widget.transformPivot({
        type: ['member', 'subtotal', 'value']
    }, transformPivotFunction);
    function transformPivotFunction(metadata, cell) {
        // Change text of array to number of columns
        customText = ["Custom", "Text", "Here", "As", "Long", "As", "Needed"]
        if (metadata.rowIndex == 1) { //only change text content for first row
            // Convert cell content to new text
            cell.content = customText[metadata.colIndex];
            cell.text = customText[metadata.colIndex];
        }
    }

    Note that  Pivot scripts can be applied only to tables in the web application and can not target widgets on export, so the script will indeed allow dashboard designers to hard code a header description in row 1 of the Pivot in the Sisense web application, but unfortunately this will not meet the requirement of that row being displayed on export. If you are interested in enhancing / supplementing this script to incorporate additional requirements, please reach out to your Customer Success Manager who can loop in our Field Engineering Services team for discovery of further development. 

    Alternatively, if a data dictionary is ultimately what you are looking to accomplish here - a text box can be added to your dashboard above / below / to the side of your Pivot table providing a description / formula for each KPI, with the added benefit of working seamlessly on export. 

    Furthermore, adding tooltips to a Pivot table is possible using instructions in the Community article here, although again will face the same limitation of only being applicable to the web application, and will not target exports. 

    Hope this helps but please let us know if any additional questions come up or if any clarification is needed and we will be happy to help.