cancel
Showing results for 
Search instead for 
Did you mean: 

Pivot2: Replace a value in a specific value in another column

Silutions
10 - ETL
10 - ETL

Have this script to find and replace a specific cell value with another value:

function getWidgetDocumentObject(widget) {
if (prism.activeWidget == null)
return document.querySelector('[widgetid="' + widget.oid + '"]').querySelector('pivot2');
else
return document.querySelector('pivot2');
}

widget.on('ready', function(widget) {
docA = getWidgetDocumentObject(widget);
// Replace cell values
docA.querySelectorAll('.table-grid__cell').forEach((element) => {
if(element.querySelector('.table-grid__content').innerText == 'Spring Breeze') {
element.querySelector('.table-grid__content').innerText = 'Fall Leaves'
}
});
});

I would like to adapt this to search and replace values in a specific column.  Any help is greatly appreciated.

Regards, Jim

1 ACCEPTED SOLUTION

harikm007
12 - Data Integration
12 - Data Integration

@Silutions ,

Below script will replace cell values. Update the variable columnIndex with index of column you need.

 

widget.transformPivot(
    {
        type: ['member']
    },
    function setCellBackground(metadata, cell) {
        
		columnIndex = 2
		
		if(metadata.colIndex == columnIndex)
		{
			cell.style = cell.style || {};
		
			if(cell.content == 'Cannon')
				cell.content = 'Cannon - Updated Text'
			else if(cell.content == 'Hickman')
				cell.content = 'Hickman - Updated Text'
				
		}

    }
);

 

Note : This script wont replace numbers from Values panel

-Hari

 

View solution in original post

2 REPLIES 2

harikm007
12 - Data Integration
12 - Data Integration

@Silutions ,

Below script will replace cell values. Update the variable columnIndex with index of column you need.

 

widget.transformPivot(
    {
        type: ['member']
    },
    function setCellBackground(metadata, cell) {
        
		columnIndex = 2
		
		if(metadata.colIndex == columnIndex)
		{
			cell.style = cell.style || {};
		
			if(cell.content == 'Cannon')
				cell.content = 'Cannon - Updated Text'
			else if(cell.content == 'Hickman')
				cell.content = 'Hickman - Updated Text'
				
		}

    }
);

 

Note : This script wont replace numbers from Values panel

-Hari

 

Hari - Exactly what I needed.  Thank you. - Jim

Voice of Customer
Impact Business Intelligence (BI) and Analytics Market Research

Click Here & Complete Dresner's Wisdom of Crowds® Market Study Survey Today!

Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Need additional support?:

Community Support Request

Don't miss out:

Earn a BETA Launch Challenge Badge!