AnalysisTemplate-SetColVal
This tutorial will demonstrate how to add a column, set up Before Formula Script and have that script run whenever data changes in other columns. This technique can be used to create an Analysis Template for repeated analysis of similar data.
Minimum Origin Version Required: Origin 8.0 SR6
// Data range on which to perform discrete frequency count range makeCol = !col(make); // Worksheet to be extracted range sourceWks = !; // Clear worksheets int sheetNum = page.nlayers; int colNum = wks.ncols - 1; if (sheetNum>1) { for (jj=2; jj<=sheetNum; jj++) { layer -d 2; } } // Tree variable to hold discfreqs outputs tree tr; // Perform discrete frequency count discfreqs irng:=makeCol rd:=tr; // String array to get result from tree StringArray sa; sa.append(tr.FreqCount1.Data1); if( sa.GetSize() != NANUM ) { // Loop to extract data for (ii=1; ii<=sa.GetSize(); ii++) { string sn$ = sa.GetAt(ii)$; // Extract condition string string cond$ = "makeCol$ = " + sn$; // Create worksheet with different Make name newsheet name:=sn$ cols:=colNum outname:=on$ active:=0; // Extract data wxt test:=cond$ iw:=sourceWks c2:=colNum ow:=on$; } }
This script will first perform a discrete frequency count on the Make column to get distinct values for Make. It will then create a new worksheet for each brand and extract data into these sheets.