Add an Average Unit Price Calculated Measure and Conditional Formatting to a NetSuite Pivot

Divide net amount by quantity in a calculated measure on a workbook pivot, then shade the result red above 500 and yellow above 100 with conditional formatting.

The quick answer

In the pivot, click Create Calculated Measure, name it, drag Net Amount, type / and drag Quantity, then Apply. Open the new measure's menu, choose Conditional Formatting then Manage Conditional Formatting, add rules with the highest threshold first, decide whether they apply to subtotals and grand totals, and Apply.

The screenshots show sample data. The company, person, dataset, customers, items and amounts are fictional. The layout, defaults and wording described here were observed in one account and release, so check them against your own.

Before you start

You need a workbook pivot built from a dataset that has a customer field, an item field, a quantity and a net amount. This guide starts from a Transaction dataset named Sales by Customer and Item Dataset that keeps posting invoice lines, and does not repeat building it. The calculated measure divides the net amount by the quantity, so both fields must be in the dataset.

01. Build the pivot

Open Analytics, click the Datasets tab and the dataset name, click Create New Workbook and choose Pivot. Drag Entity and then Item into Rows, and Quantity and then Net Amount into Measures. Each customer lists the items it bought, with Quantity (Sum) and Net Amount (Sum) for each pair. In the account reviewed the pivot drew as soon as each field landed.

Quantity and Net Amount for each customer and item.

02. Create the calculated measure

Click Create Calculated Measure. The Calculated Measure page asks for a Name and a Definition. Type Average Unit Price, drag Net Amount into the definition, type the divide operator / and drag Quantity. The dots beside each field change its aggregate function; here both stay at Sum. Click Apply.

The definition divides summed net amount by summed quantity.

The measure joins Measures with a calculator symbol, and the pivot gains an Average Unit Price column. Each cell sums its net amount and its quantity first and then divides, so 390.00 over 8 gives 48.75 for Bramble Foods and Door Gasket Kit, even though its two invoice lines have different prices.

Average Unit Price beside Quantity and Net Amount.

03. Add the conditional formatting rules

Hover over Average Unit Price in Measures, open its menu, choose Conditional Formatting and then Manage Conditional Formatting. The dialog names the Selected Field and the Rule Type, Numeric. Set rule 1 to greater or equal 500 and choose a red from the palette. Click the plus to add rule 2, greater or equal 100, and choose a yellow. Rules are checked in order and the first one a value meets sets its color, so put the highest threshold first. Clear Apply to subtotals and grand totals to leave totals unshaded, and click Apply.

Rule 1 is 500 or more in red; rule 2 is 100 or more in yellow.
Red from 500, yellow from 100, no color below 100.

Check the result

  1. Average Unit Price cells of 500 or more are red: 820.00, 640.00, 790.00 and 650.00.
  2. Cells of 100 or more but under 500 are yellow: 124.00, 140.00 and 120.00.
  3. Cells under 100, such as 48.75, 24.00 and 98.00, keep no color.

04. Check the subtotals

Click the Totaling sigma button, choose Bottom for Rows and click OK. Each customer ends with a Total line and a Grand Total row closes the pivot. Their Average Unit Price is the total net amount over the total quantity at that level, for example 217.29 for Bramble Foods. Because Apply to subtotals and grand totals was cleared, none of them is shaded, even 217.29 and 131.27, which would be yellow if the option were on.

Totals are calculated but unshaded.

05. Save the workbook

Click Save, type a name such as Sales by Customer and Item Pivot in Save Workbook As: and click Save. The confirmation reads Workbook has been saved. Saving keeps the pivot layout, the calculated measure and its rules; the dataset stays separate.

Common questions

How do I create a calculated measure in a NetSuite pivot?

In the workbook pivot click Create Calculated Measure under Measures, enter a name, build the definition from dataset fields and the operators +, -, * and /, and click Apply. The measure appears in Measures with a calculator symbol.

Is the calculated measure an average of the row ratios?

No. Each field in the definition is summarized over the rows of the pivot cell first, and the arithmetic is done on those summaries. A subtotal or grand total is the ratio of the summed values at that level, not an average of the ratios above it. For a row-by-row average, use a row-level formula field and the Average summary type.

In what order are conditional formatting rules checked?

In the order listed, and the first matching rule wins. Put the highest threshold first, or every value above it would take the color of the lower rule.

What does Apply to subtotals and grand totals do?

It decides whether the rules also run against subtotal and grand total values. It is checked by default. A total is judged on its own value, not on the cells under it.

Which summary types can a measure use?

The measure menu lists Average, Sum, Median, Count, Count (Distinct), Min and Max. Which of them a field offers depends on its type and the release; blank values are generally left out of Average and Median.