Summary field based on value of another field

Good day,

On the attached ddsp, I need to sum the AECProjInvoiceProgressTmp/@PreviousBilling and AECProjInvoiceProgressTmp/@PendingBilling fields but only include lines where the AECProjInvoiceProgressTmp/@ContractValue field is not 0.

I would’ve sat longer to try and figure this out but testing is about to start and I’ve run out of time.

Thank you for your help.

Standard template 18 - Progress Phase.docx (82.3 KB)
WLPPhaseGroupingProjInvoice.PMIPProjectInvoicing (4).ddsp (193.0 KB)

Hi @Nicky,

I’m not quite sure if I understood your case correctly. If not, please let me know.
This will require a slight adjustment to our approach from the manual, where we manually calculate the running total.

In the first step, I will add a new var tagging element near the beginning of the document, similar to how variables are declared in programming, with an initial value of 0. I will name it ‘SUMBilling’.

Then, inside the group tagging element, I’ll add the same var tagging element with the same name. However, instead of setting it to zero, I’ll use an XPath expression to sum AECProjInvoiceProgressTmp/@PreviousBilling and AECProjInvoiceProgressTmp/@PendingBilling. Since the filter ensuring AECProjInvoiceProgressTmp/@ContractValue is not 0 is already applied at the group level, I’ll skip that part.

Xpath expression:

var-element-value('SUMBilling') + AECProjInvoiceProgressTmp/@PreviousBilling  + AECProjInvoiceProgressTmp/@PendingBilling

This will ensure that for each line, the calculation will be done separately, and the sum will then be stored for each line within the var tagging element.

Once all the lines are calculated and we are outside the group tagging element, we can add a field tagging element to display the final result.

However, we would need to use the following XPath expression.

var-element-value('SUMBilling')


Standard template 18 - Progress Phase_Test.docx (83.0 KB)

Hi Amir,

Apologies, I should have clarified further - I need the sum total of the previous billing in the subtotal line, and the sum total for the pending billing in the subtotal line. Like adding up the column total.

Currently the total for the current billing is $22,000.00, but if you add the column that’s not correct. It’s because it adds in the current billing for the lines where the contract value is 0. Those lines are not displayed, and I need to exclude them from the total.

Sorry for the confusion.

Hi @Nicky

Then in this case just change the Xpath expression from my post and set it just to:

var-element-value('SUMBilling') + AECProjInvoiceProgressTmp/@PendingBilling

This will result in the sum of the field values, the current billing values with in the group tagging element. You could do the same for PreviousBilling, but you will need to add an additional var tagging element to cover this calculation.


Standard template 18 - Progress Phase_Test2.docx (83.1 KB)

Thank you, this works perfectly. :slight_smile: