BILT Speaker

BILT Speaker
RevitCat - Revit Consultant

Monday 5 August 2019

Using Count Parameter in Revit Schedule Formulas

Anyone who has tried to master Revit Schedules would have encountered all kinds of limitations.  One of those is the limitations on which parameter types can be used in a calculation:

These parameter types can be used in formulas:
  • Number
  • Integer
  • Length
  • Area
  • Volume
  • Angle
  • Yes/No
  •  <Family Type..>
  • etc
They are all basically a number or a choice between items that have a number hidden behind them (Y/N  or <Family Type..>

The following parameter types cannot be used in formulas:
  • Text
  • URL
  • etc
They are some kind of text, which is all too hard for Revit to cope with (poor little Revit).

There is another kind of schedule parameter, which is not listed above (because it is a system parameter that you cannot choose from a list of types): 

        "Count", which is just a number (always = 1 for each item).


However, if you try to use this in a schedule formula, Revit gets very uppity and says you cannot.


This is unprecedented in Revit - a message that actually explains why it can't do what you want!
  • In case its not obvious what this means, it is referring to when you uncheck "Itemise every instance" under the Sorting/Grouping tab.

However, it is quite likely that you do actually want to perform a calculation on the combined result when multiple elements appear on the same row.  If not that, you may want to calculate per item and then total up the results of your calculation.  Here is my workaround:

Count Dracula Formulas

In your schedule, you can create your own "Count" parameter:
         a Calculated Value with a formula = 1

You could call it "Dracula", but that might confuse everyone later, so its better to use something more prosaic like "MyCount"
MyCount formatted to No Calculation

Don't forget to format your Count Dracula parameter to 'Calculate Totals' otherwise it will list only 1 even for multiple elements per row (as above).
MyCount formatted to Calculate Totals

Once you have 'MyCount' working, you can include it in a formula:
  • You may have a numeric parameter - say 'Num Shelves', which represents the number of shelves in a unit.
  • This can be multiplied by your Count parameter in a new 'ShelfCount' calculated value

Revit is quite happy to include "Dracula" or "MyCount" in the formula even though it is doing the same job as the system parameter 'Count'.

The formula could include an if statement:

Or you could put a formula directly into your 'MyCount' parameter

NB  . The last two formulas were somewhat superfluous, but just shown to demonstrate that you can create formulas with your own Count parameter.  For a more realistic example, refer to my previous post on Hiding Zeros in Schedule Formulas

This workaround removes one of Revit's many limitations - the programmers obviously put that one in deliberately to prevent "wrong workflows", but in reality they didn't anticipate all our requirements with schedule formulas. [Yes, my spellchecker doesn't like "formulas", but then I never liked learning Latin, so I'm not changing it!]

For more information about Revit Schedules, refer to this index of Schedule blog posts
 

10 comments:

  1. What happens when Count is greater than 1?

    ReplyDelete
    Replies
    1. You don't have to hardwired the value 1 as a formula. You can make it a value that can be changed by users (to 0 or 2, 3 etc)- but if you do that then you'll need to put in error checking formulas too.

      Delete
  2. Perfect! Working! Many Thanks :)

    ReplyDelete
  3. Can you answer this? I wanted to run a formula such as this:
    if(Identify Quantity as Lot, "lot", if(qtyformula = 5, "5", if(qtyformula = 4, "4", if(qtyformula = 3, "3", if(qtyformula = 2, "2", if(qtyformula = 1, "1", ""))))))

    where "qtyformula" is my built counter, but even with "calculate totals" clicked it still always shows up as 1 in my results

    ReplyDelete
    Replies
    1. Hi Unknown. The count parameter has to be a number or integer. Your formula has "" quotes, which implies you are using text parameters, which won't work.

      Delete
    2. hi RevitCat, I guess I should explain:
      Im trying to be able to substitute the word "Lot" for an actual count in certain instances, so I did the following:
      1) created a count parameter QTYFORMULA just as you instructed, and added the"caculate totals" feature, which does in fact count just like count does.
      2) Then i created a second calculated value QTY (which is a text parameter) and inserted that formula.

      In every other case where i have converted a real number to text this has worked. its a standard swap-out parameter formula - it should look at QTYFORMULA, see that the calculated value is some number and match it to the list - but it always sees QTYFORMULA as either 1 or 0, never 5... Mind you, I normally use this formula to print the result of a shelf that got streched or something, so the math is visible in a parameter somewhere....

      Delete
    3. Your calculation works per line, not on the totals, even when you don't itemize every instance. Have a look at "Using Totals in Formulas" on my blog to solve this

      Delete
  4. Extremely useful and well explained. Thank you.

    ReplyDelete