Resources / Article
NetSuite saved search formula examples with CASE WHEN
NetSuite saved search formula examples: CASE WHEN, blank checks and today's date, plus which formula type to pick on each subtab.
You enter a saved search formula on the Criteria subtab or the Results subtab, and the formula type you pick there decides how NetSuite validates the expression. The examples below are expressions you can type into a search, covering CASE WHEN, NVL2, CURRENT_DATE and TO_NUMBER.
Where do you enter a formula in a saved search?
On the Criteria subtab, the Filter column lists formula types alongside the field names. Formula (Text) is the type Oracle names for character manipulation with regular expressions, and Formula (Numeric) suits numeric calculations, because validation rules change with the type you choose (Oracle help). Formula (Date) appears in that same Filter list.
The Results subtab puts the choice in the Field column and offers a longer list, including Formula (Currency), Formula (Date), Formula (Date/Time), Formula (Percent) and Formula (HTML) (Oracle help).
Formula (Text) examples
Oracle's Formula (Text) example for search results compares a due date with the current date and returns one label or the other (Oracle help):
CASE WHEN {duedate} < CURRENT_DATE THEN 'Past due' ELSE 'Open' END
Oracle's second Formula (Text) example joins a quantity to an item name (Oracle help):
{quantity} || 'x ' || {item}
Formula (HTML) builds a link from the entity ID and the entity name, and Oracle's example opens the record in a new tab (Oracle help). Oracle's NVL2 example returns a green "Approved" span when a field holds a value and a red "Not Approved" span when it is empty.
Integer Number fields show only 13 characters in a saved search, so switch to Formula (Text) when the value runs to 14 digits or more (Oracle help).
Line numbers on transaction lines
Line numbers come from a custom transaction column field. Set the type to Integer Number, clear Store Value, apply the field to the transactions you want, set the display type to Disabled, tick the Formula box on the Validation & Defaulting subtab, and enter {linenumber} as the default value (Oracle help). The Applies to subtab is where you tick the transactions that carry the field, and where you tick Print on Standard Forms. The line number shows when you view the transaction record. To get it onto a printed form, open the custom transaction form, go to the Printing Fields, Columns subtab, and tick Print/Email against the field.
Formula (Numeric) examples
Oracle's Formula (Numeric) example is a field reference, {field_id} (Oracle help). Formula (Currency) wraps a currency field with TO_NUMBER, and Oracle's example is TO_NUMBER({amount}). Formula (Percent) takes an expression such as % of total 30/100.
Formula (Date) examples
Formula (Date) uses TO_DATE to turn a text value into a date, and Oracle's example passes a date string with a MM/DD/YYYY format mask (Oracle help). For the current date and time, use {now} in a Formula (Date/Time) result. To test whether a date has passed, compare a date field with CURRENT_DATE inside a CASE WHEN.
Example: overdue invoices in INR
Amounts in INR.
Criteria:
- Type is Invoice
- Status is Open
- Formula (Text):
CASE WHEN {duedate} < CURRENT_DATE THEN 'Past due' ELSE 'Open' END, with the filter set to is Past due
Results:
- Date
- Name
- Formula (Text): the same CASE WHEN expression
- Amount
- Formula (Currency):
TO_NUMBER({amount})
| Date | Label | Amount (INR) |
|---|---|---|
| 12/03/2025 | Past due | 2,45,000 |
| 28/03/2025 | Past due | 87,500 |
| 05/04/2025 | Past due | 1,20,000 |
Total overdue: 4,52,500 INR.
Keep the searches your client signs off in the BRD template for ERP implementation so the definitions survive the handover.
Trade-offs
- Validation varies by formula type, so an expression accepted under one type can be rejected under another (Oracle help).
- A Workbook formula field cannot be built on another formula field (Oracle help).
- A Workbook formula value updates when you refresh the dataset or the visualizations attached to it, so what you see reflects that refresh (Oracle help).
- Integer Number fields show only 13 characters in a saved search, which pushes long values into Formula (Text) (Oracle help).
How do saved search formulas differ from SuiteAnalytics Workbook formulas?
Saved search formulas are expressions you add on the Criteria subtab or the Results subtab (Oracle help). SuiteAnalytics Workbook gives you custom formula fields that mix NetSuite fields with SQL formula functions, and you set an output type when you create the field (Oracle help). Output types include Boolean, Date, Datetime, Float, Integer, String, Clobtext, Percent and Duration (Oracle help). A Boolean field returns true, false or a null value. A formula field goes into a dataset from the Data Grid, where it can act as a filter or feed any visualization built on that dataset. Workbook also supports formula context values such as #converted. The Formula Builder lists basic formulas for each output type, including a Boolean CASE WHEN on transaction days overdue.
KPI scorecard formulas
KPI scorecard formulas live in the portlet. Open the portlet menu and choose Customize, then go to the KPIs tab under Content and pick a formula from the KPI list (Oracle help). Type the expression in the Formula column, or open the Formula popup from the Set Formula icon, where the Function list adds functions and the KPIs dropdown adds KPI IDs. You can also edit the expression directly in the Formula field and click Set when you finish. A custom KPI used in a formula is set up on the Custom subtab.
Common mistakes with saved search formulas
- Picking a formula type that does not match the calculation, since validation varies by type (Oracle help).
- Missing the 13-character display limit on Integer Number fields (Oracle help).
- Building a Workbook formula field on top of another formula field (Oracle help).
- Ticking Store Value on a line number field. Oracle tells you to clear that box (Oracle help).
FAQ
Can I use CASE WHEN in a saved search formula?
Yes. Oracle shows CASE WHEN in the Formula (Text) example for search results (Oracle help).
Does NetSuite have a function for empty fields?
Oracle's Formula (HTML) example uses NVL2 to return one string when a field has a value and another when it does not (Oracle help).
Can a formula reference another formula?
In SuiteAnalytics Workbook, no (Oracle help).
Where do KPI scorecard formulas live?
In the KPI scorecard portlet (Oracle help).
The quick way is mark.: it reads the saved search and the records behind it, finds the cause and tells you the exact fix. Try it free.
Sources
- docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/bridgehead_N2832808.html
- docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_1206103522.html
- docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_1544128605.html
- docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N613116.html
- docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N661053.html
- docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N661334.html
Have mark. check this against the client's own files
mark. reads the client's files and sets each point against them, with the source beside it.
Twenty minutes on one client folder. Your 21-day trial opens on the call.