Forum Discussion

DXC's avatar
DXC
Cloud Apps
10-15-2024
Solved

Funnel Chart % of Total Calculation

Hi, can you help us with a script to calculate the % of total for each portion of a funnel chart instead of the % of the top category?

  • Hi DXC ,

    I hope this script works for you.

    widget.on('processresult', function(se, args){	
    
    	total = args.result.series[0].data.reduce((acc, el) => (acc = acc + el.y), 0)
    	args.result.series[0].data.forEach(el => el.custom.percent = (el.y / total) * 100)
    		
    });

     

     

     

    -Hari

2 Replies

  • harikm007's avatar
    harikm007
    Data Warehouse

    Hi DXC ,

    I hope this script works for you.

    widget.on('processresult', function(se, args){	
    
    	total = args.result.series[0].data.reduce((acc, el) => (acc = acc + el.y), 0)
    	args.result.series[0].data.forEach(el => el.custom.percent = (el.y / total) * 100)
    		
    });

     

     

     

    -Hari