I am trying to create a form that would sum the line items based on criteria like what you would do with SUMIF in an excel spreadsheet. For example I would like to sum the line items that are for Admin and have account 7196 only.
I am trying to create a form that would sum the line items based on criteria like what you would do with SUMIF in an excel spreadsheet. For example I would like to sum the line items that are for Admin and have account 7196 only.
Hello Will,
Currently SUMIFS is not supported as it is not part of the OpenFormula standard, but I have put in a feature request to support the formula in a future release. For now, the following JavaScript should suffice, just a minor tweak to the existing code:
$(document).ready(function () { $('.cf-table-block').on('blur','input',sumtotal); $('.tax').on('blur','input',sumtotal); $('.shipping').on('blur','input',sumtotal); function sumtotal() { var sum = 0; $('.cf-table-block tbody tr').each(function () { var s = 0; s = parseNumber($(this).find('.price input').val()) * parseNumber($(this).find('.quantity input').val()); $(this).find('.subtotal input').val(s); if (($(this).find('.department select').val() == "Admin") && ($(this).find('.id input').val() == "7196")) { sum += s; } }); $('.total input').val(sum); } function parseNumber(n) { var f = parseFloat(n); return isNaN(f) ? 0: f; } });
Note that to use this code as-is, you must set the GL Account ID to have the class "id" (which admittedly is probably not the best name given CSS terminology...) in order to check its value.
Hope this helps!
Just thought I would post a link to may unaswered post as well. This is exactly what we are trying to accompish. We are able to get the SUMIF to work with one criteria. However we also need to check two criteria.
https://answers.laserfiche.com/questions/87803/Forms-10-Calculations
That worked. Thank you!
Hi,
SUMIFS is supported in Forms 10.1.
SUMIFS( Reference R ; Reference R1 ; Criterion C1 [ ; Reference R2 ; Criterion C2 ]... )
Thank you.