Forum Discussion

rahuldhomane's avatar
02-15-2022
Solved

+ sign for values in Blox

Hi,

I was looking for a way to add '+' sign to a value whenever the result is positive in Blox. Please let me know if there is a way to add this feature

 

Thanks in Advance!

  • rahuldhomane ,

    Please try this script. Here update the variable panelName with name of panel where you need to apply this feature:

    widget.on('processresult', function(se, ev){
    	
    	panelName = 'Revenue'
    	
    	panelIndex = ev.rawResult.metadata.findIndex(el=>el.PanelName == panelName)
    	
    	if(panelIndex >= 0)
    	{
    		$.each(ev.result, function(index, value){
    			if(value[panelIndex].Value > 0)
    				value[panelIndex].Text = '+' + value[panelIndex].Text
    		})
    	}
    })

    -Hari

2 Replies

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    Data Warehouse

    rahuldhomane ,

    Please try this script. Here update the variable panelName with name of panel where you need to apply this feature:

    widget.on('processresult', function(se, ev){
    	
    	panelName = 'Revenue'
    	
    	panelIndex = ev.rawResult.metadata.findIndex(el=>el.PanelName == panelName)
    	
    	if(panelIndex >= 0)
    	{
    		$.each(ev.result, function(index, value){
    			if(value[panelIndex].Value > 0)
    				value[panelIndex].Text = '+' + value[panelIndex].Text
    		})
    	}
    })

    -Hari