Uploaded image for project: 'ZK Spreadsheet'
  1. ZK Spreadsheet
  2. ZSS-852

Support condition in SUMPRODUCT function

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Normal Normal
    • 3.7.0
    • 3.6.0
    • None
    • Security Level: Jean

      Problem Description

      In Excel, users can specify condition for an array to just calculate some cells with SUMPRODUCT()
      For example,

      =SUMPRODUCT(--(A1:A3="John"),(B1:B3),(C1:C3))

      or simpler
      =SUMPRODUCT((F12:F21=1)*(G12:G21="Z")*H12:H21)

      It will only calculate those rows that its A column is John.

      Reference


      Workaround

      • Split it as arguments.
        Split complicated syntax as separate arguments and process arguments in custom function method.
        The syntax might be:
        MYSUMPRODUCT(range1, criteria1, range2, criteria2, ...)
        e.g.
        MYSUMPRODUCT(A1:A3, "somevalue", B1:B3)
      • Turn it to a string
        Turn the complicated syntax as a string with double quote like "--(A1:A3=some value)", or simplify syntax to "A1:A3=some value", Then parse it by your own.
      • Use another Excel function.
        using SUM and SUMIF can achieve the same result as SUMPRODUCT. Please see the example in attached Excel file.

      The first 2 workarounds' drawback is they are not compatible with Excel SUMPRODUCT, so users have to convert Excel SUMPRODUCT to your custom one in order to work in ZSS.

        1. sumif.png
          sumif.png
          5 kB
        2. sumproduct.xlsx
          9 kB
        3. sumproduct-fixed.png
          sumproduct-fixed.png
          7 kB

            henrichen henrichen
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: