1.31 FAQ-146 How can I filter dataset based on custom conditions in Layer Contents?

Last Update: 7/8/2018

When adding or removing data plots in Layer Contents dialog with dataset from multiple workbooks and worksheets , finding the favorite columns in the left panel would be a time-consuming task. Apart from using the built-in Available Data Drop-Down List , you can also add custom conditions in this list to do a more efficient filtering.

Suppose you want to filter columns with Short Name A (i.e. Col A) from all the columns of the same project in the Layer Contents left panel. To begin with adding custom conditions:

  1. Open Code Builder, create a new C file then enter the following function:
    BOOL MySelection(OriginObject& obj, int nType)
    	switch ( nType )
    		return TRUE;
    			WorksheetPage wksPage;
    			wksPage = (WorksheetPage)obj;
    			return wksPage.IsValid();
    			Worksheet wks;
    			wks = (Worksheet)obj;
    			return wks.IsValid();
    			Column col;
    			col = (Column)obj;
    			if ( !obj )
    				return FALSE;
    			string strName;
    			return strName.Compare("A") == 0;
    	return FALSE;
  2. Compile the file and build the workspace .
  3. To add the custom condition filter into the Available Data Drop-Down List of the Layer Contents , open the Origin.ini in User File Folder and paste the following script into the end of the Origin.ini file. Save and close the file.
    User Defined=Oubtn.ini
  4. Open the Layer Contents by clicking Graph: Layer Contents... and click the Available Data Drop-Down List on the left panel. You can see the ShowColAOnly is shown at the bottom of the list.
  5. Select the ShowColAOnly in the drop-down list. All columns with short name of A in this project will be filtered in the left panel.

Note: You can add the created C file in the System Folder in Code Builder so your functions are always ready when Origin starts.

Since Origin 2018b, you can exclude some worksheets from showing in Plot Setup and Layer Contents dialogs by right clicking worksheet(s) tab and tag as Exclude from Plotting Dialogs.

Keywords:filter, layer content, column