Trying to add Booleans formatted as number but not working

I’m generating a legal document and depending on user input some sections will show if they have a value, or be hidden if they are empty.

Based on that, the numbers of the subsequent sections will be different.

For example, Clause 1, 2 & 3 are always present in the document.
Clauses 4, 5 & 6 are only present in the document when they have a value.
Clauses 7-10 are always present.

So, let’s take Clause 7 as a demonstration (although the same logic will apply to 8,9 & 10).

If there are no values in 4, 5 or 6, Clause 7 should now be numbered Clause 4 - it will come after Clause 3. And the following clauses will be 5,6 & 7.
If there is a value in Clause 5 but not in 4 or 6, then Clause 5 will become Clause 4 and Clause 7 will become Clause 5 (the next number) and the following numbers will be 6,7 & 8.

So, for numbering the original Clause 7, I’ve written an expression that Does a Search for the Count of Clauses 4,5 & 6 > 0 and formats them as a number, in this case a Boolean, where yes = 1 and no = 0. Then I add 4.

So if 4,5 & 6 were empty ( Count not > 0) the value should be 0 and the number of Clause 7 would be 4 - 0+0+0+4.

If all 3 had values ( Count > 0, yes = 1 )then Clause 7 would remain 7 - 1+1+1+4 = 7.

That’s all good in theory, but when I try to add the Boolean values in my expression, they don’t add. They only ever sum to 1.

In my screenshots, there are values in all sections so I would expect to see 7, however I only see 5.

It says that the expression should evaluate to a number so I don’t see why it doesn’t work. Any ideas?

Screenshot 2024-02-25 at 21.41.41

Screenshot 2024-02-25 at 22.01.44

I’ve not read your post but the chances are your database structure isn’t great. You will want to try something along the lines of:

Data type: Clause
Option set: Clause Type (e.g Residual Estate, Non-Disclosure, Registered Parties - the name of this section).

Then, just have a repeating group of the clauses (probably from a List of Clauses on a Document data type) and display Current cell’s index as the number.

Have the text for each clause type in the cell of the repeating group, and only show the relevant one based on Current cell’s Clause Type (e.g you’ll have a text for Residual Estate for example - make them not visible by default and show if Current cell’s Clause Type is Residual Estate)

When you’re viewing it in the debugger do all the calcs work correctly? That would normally give some hints.

Id suggest running this logic in a workflow sequentially since these types of long dynamic expressions can be annoying to maintain

1 Like

Yeah thanks. Didn’t think to look in the debugger.

Can see that it’s not working as expected. I expected that it would take each expression separated by the + as a unique value and add them, however it’s taking half of each expression, then returning the boolean each time, hence only the value of 1 overall.

I have a workaround which involves repeating three versions of the text with a separate number each, eg. 7,8 or 9, and then setting conditionals to show/hide them based on the same logic I was trying to implement in the one expression.

It’s longer and messier and contains way more groups, however will just have to do.

Thanks for your help.

1 Like

One other option, have a group for each “do search for” expression, with the group type of number, then calculate the sum of those groups, could be an in between option :slightly_smiling_face:

1 Like