FIRSTOCCURANCE should happen based on High number


Hi All,


Is it possible to get FIRSTOCCURANCE based on Highest Number?


As per the below Example:

1. "PRODUCT A" has the Highest Transaction number- 4,000 in the second Hierarchy(Bucket 2). "PRODUCT A" Will TRUE Under BUCKET 2 Parent.

2. "PRODUCT C" has the Highest Transaction number- 3,000 in the first Hierarchy(Bucket 1). "PRODUCT A" Will TRUE Under BUCKET 1 Parent.



Please suggest.






  • @g.mahesh Uma

    I really like this use case, great question Uma. When I look at what you're trying to do it looks like you want Product A with the highest value to show first. If that's the case, I would recommend using the RANK() function.

    You will need a Boolean line item that looks for RANK = 1. Than you can filter on the Boolean.

    Hope that helps!

  • @g.mahesh 


    I am coming at this from a different position than @JaredDolich.. Take a look at the below as I think this will work for you, but in order for it it work, you have to have the architecture correct.


    First, on your hierarchical list, make sure it is a numbered list (I am sure you already have that), with the the Display Name being list formatted to a Flat list (in my case Products)


    Composite List numbered list:



    Display Name format



    Flat List (Product)



    Data Module



    Now the magic.  Create another module which is dimensionalized by Product (my flat list which is used by the Display Name in the composite list).  Create a line item, I named it Max with the formula: GMesh.Value[MAX: 'P2 Product'.Display Name]



    Now, go back to the original module and create a new line item, (Is First?) formatted as Boolean with the formula: Value = GMesh Max.Max[LOOKUP: 'P2 Product'.Display Name]




    This is will work better than the Rank function because a) I am not sure Rank will get you where you want to go and b) this is solving the issue with dimensionality which will be more scalable.


    Hope this helps,




  • Sweet, @rob_marshall 

    An exquisite solution!

  • @JaredDolich 


    So I was thinking about my comment that this couldn't be used with Rank and it really bugged me.  I did prove it out to work with Rank, but i still don't think it should be used due to the overhead that Rank adds.





  • @rob_marshall 

    Your solution makes complete sense. RANK, I imagine, is much more processing intensive than MAX. 

    @g.mahesh use case lends itself nicely to MAX. However, if the conditions change where they want the top 2, or they want just the second, they can may have to use RANK. 

    This is the joy of Anaplan, IMHO. So many options to fit the requirements, some better than others. Always learn something new from you @rob_marshall. Thank you!!