Sisense Community logo
    • Community Feedback
    • Chapters
    • Events
    • Forums
      • Help and How To
      • Product Feedback Forum
      • Strategy & Use Cases
    • Blogs
    • KB Docs
      • KB Docs
      • Add-Ons & Plug-Ins
      • APIs
      • Best Practices
      • Blox
      • CDT
      • Cloud Managed Service
      • Data Models
      • Data Sources
      • Embedding Analytics
      • How-Tos & FAQs
      • Onboarding
      • PySisense
      • Security
      • Sisense Administration
      • Sisense Intelligence & AI
      • Troubleshooting
      • Widget & Dashboard Scripts
    • Support
    • Learning
      • Sisense Academy: Free Courses and Certifications
      • Official Developer Documentation
      • Official Product Documentation
      • Official Sisense Youtube Channel
      • Sisense Compose SDK Playground
    • Use Case Gallery
    All PostsDiscussionsBlogsIdeasQuestions
    Leaderboards
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    Discussions
    • Knowledge Base DocsChevronRightIcon
    • How-Tos & FAQsChevronRightIcon
    Hide a column - Linux Pivot

    Sometimes we would like to hide a column in our pivot table so we will be able to apply a specific logic or order the table by a column without displaying it.

    The following script will allow you to hide the needed columns in your Pivot table.

    To implement it, please make sure to:

    • Adjust the number of columns according to your widget
    • Place 0 for the column you'd like to hide
    • Save the script
    • Refresh the page

    The following script is adjusted for a pivot table with 5 columns, hiding 2 of them:

    var newWidth = {
    0: 100,
    1: 0,
    2: 100,
    3: 0,
    4: 100
    }
    var columnsToRemove = []
    var passed = -1
    var wasExecuted = false
    widget.on('processresult', function(widget, args){
    if (!wasExecuted) {
    args.result.metadata.forEach(function(e, index) {
    e.panel
    if (e.panel != "scope" ) {
    index = Object.keys(newWidth).length - index+passed;
    if ( typeof(newWidth[index]) !== "undefined" ) {
    e["format"] = {"width":newWidth[index]};
    }
    if (e.format.width === 0) {
    columnsToRemove.push(index)
    }
    }
    else {
    passed ++
    }
    })
    wasExecuted = true
    }
    })
    widget.on('ready', function() {
    columnsToRemove.forEach(function(item) {
    var selector = "[class*=table-grid__cell--col-" + item +"]";
    $(selector, element).each(function(i, lmnt) {
    $(lmnt).text('')
    })
    })
    })
    

    Here is an example of the above script:

    Before:

    Community_Admin_0-1634394440994.png

    After:

    Community_Admin_1-1634394440939.png
    Community_Admin
    By
    Community_Admin
    Posted 4 years ago·Last reply 8 months ago
                                           
             
    6 comments

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                   
    daat

    daat

    ·8 months ago

    Does not work in Linux either.

                                           
    Sisense User

    Sisense User

    ·4 years ago

    This script doesn't seem to work when there is conditional formatting enabled on the value column. 

                                           
    Rajesh

    Rajesh

    ·4 years ago

    Thanks for the script.
    When we tried this on a widget that has % values ( decimal values formatted as % values) though we are able to hide the column it is resetting the % values format back to decimals when the dashboard is refreshed.

    Is there a way we retain the formats and still able to hide the columns?

     

                                           
    rklingensmith

    rklingensmith

    ·4 years ago

    awesome thanks so much Ophir_Buchman 

                                           
    Ophir_Buchman

    Ophir_Buchman

    ·4 years ago

    Hi rklingensmith,

     

    Yes - Windows uses Pivot 1.0 charts while Linux uses Pivot 2.0

    The HTML labels are different for both pivot chart tables.

     

    As this code relies on HTML class names (selector = "[class*=table-grid__cell--col-" + item +"]") - It won't execute as expected.

     

    A "Pivot 1.0 Customization" article will soon be available in the Sisense Knowledgebase to cover the code for this functionality.

     

    Per the second question:

    A similar code may work if you tweak it a bit to ignore the last column's occurance

     

    Ophir

                                           
    rklingensmith

    rklingensmith

    ·4 years ago

    I am unable to get this to work for Windows. Would this require different code?

    Also! Second question. If we are looking at 2 Values but only want to show the second value in the last column, would this "column hide" code work? (screen shot below)

     

     

                                           
                                                                                     
    •                                                              
    •                                                              
    •