ISFIRSTOCCURRENCE in Anaplan
ISFIRSTOCCURRENCE is TRUE the first time a value appears in a list, so it is used to count unique values. First means list order, not date. To count members of a list, ANY is usually the better choice.
By Nikolai Starostin, Anaplan architect at MaxPlan and Master Anaplanner. Updated .
What is the syntax of ISFIRSTOCCURRENCE?
The values can be of any format. The list must be a dimension of the line item that holds the formula, and the result is a Boolean. First follows the order of the list in General Lists. If the list isn't sorted by date, the first occurrence isn't the earliest.
| Order | Customer | ISFIRSTOCCURRENCE |
|---|---|---|
| 1 | Acme | TRUE |
| 2 | Birch | TRUE |
| 3 | Acme | FALSE |
| 4 | Birch | FALSE |
How do you count unique values in Anaplan?
In the Orders module, flag the first order of each customer and leave blanks out. Call it Is first:
Then count it in a number line item with a Sum summary. The total of the Orders list is the number of customers, 2 above.
Is there a faster way than ISFIRSTOCCURRENCE?
Yes, when the value is an item of a list, as Customer is here. Go through a module by Customer instead of comparing orders with each other. Is order is TRUE for every order. In Has order, by Customer:
Then count it, again with a Sum summary:
The answer is the same 2, and you can now filter on which customers they are. Keep ISFIRSTOCCURRENCE for values that aren't in a list, such as text. See ANY and ALL.
Why is ISFIRSTOCCURRENCE slow?
Planual 2.02-20 puts it with RANK: calculation-intensive functions that can't multi-thread. In Classic it stops at 50 million cells and the model rolls back; Time, Versions and summary cells don't count. Check your own model: the full analysis flags it over an estimated million items.
Does ISFIRSTOCCURRENCE work in Polaris?
It does, but Anaplan writes "We strongly advise you to avoid ISFIRSTOCCURRENCE in Polaris", because it performs poorly on line items with many dimensions. Polaris has no 50 million cell limit, can search Time, and can't use a list subset. Classic is the other way round on all three.
Sources
Check your model
Upload the line-items blueprint. The basic check runs in your browser and needs no email.