How to convert a particular column value (i.e rows) into seperate columns?

I have a table called table1 and I want to convert column C values into column as show below:

Hi @khatanaashish

Thanks for reaching out! We don't really have a convert method, but it seems like this can be doable with some Javascript or with custom components.

To clarify, do you want the table1 to have columns A, B, C, xyz1, xyz2, and xyz3? Should there be any row data for xyz1, xyz2, and xyz3?

I was able to do it using the following: (Hope it helps someone)

// Input data from the table
const inputData = {{table.data}}; // Replace with your actual data source

// Create an array to store the combined data
const outputData = [];

// Create a set of all unique dates
const allDates = new Set();

// Iterate through the input data to populate allDates and the outputData
inputData.forEach(row => {
const { Account_ID, Product_ID, Proj_Dt } = row;

// Parse the Proj_Dt date
const projDate = new Date(Proj_Dt);
const formattedProjDate = projDate.toISOString().split('T')[0]; // Format to "yyyy-MM-dd"

allDates.add(formattedProjDate);

// Create a new object for each row with the accumulated dates
const combinedRow = {
Account_ID,
Product_ID,
Proj_Dt,
[formattedProjDate]: "", // Create a property with the formatted date and set it to an empty string
};

outputData.push(combinedRow);
});

// Iterate through outputData to ensure allDates are present for each combination
outputData.forEach(row => {
allDates.forEach(date => {
if (!row[date]) {
row[date] = "";
}
});
});

return outputData;

1 Like

Thank you for sharing!