hyperformula icon indicating copy to clipboard operation
hyperformula copied to clipboard

SUMIF not working on dates

Open AJNandi opened this issue 3 years ago • 2 comments

Description

SUMIF does not work when dates are included in the conditional values range and the criterion is also a date. It seems to be failing regardless of whether the date has been parsed using dateFormats.

Steps to reproduce

    const engine = HyperFormula.buildFromArray([
      ['1', '4', 43384, '25000'],
      ['2', '2', '11/10/2018', '15000'],
      ['=SUMIF(C1:C3, "11/10/2018" ,D1:D3)']
    ], {dateFormats: ['DD/MM/YYYY']})
    expect(engine.getCellValue(adr('A3'))).toEqual(40000)
const engine = HyperFormula.buildFromArray([
      ['1', '4', 43384, '25000'],
      ['2', '2', '11/10/2018', '15000'],
      ['=SUMIF(C1:C3, 43384 ,D1:D3)']
    ], {dateFormats: ['DD/MM/YYYY']})
    expect(engine.getCellValue(adr('A3'))).toEqual(40000)

Both tests fail with a result of 25000

MBP 2021 macOS 12.3 node v16.13.0 npm v8.1.0

HF version: 1.3.1

Seems like the issue is that DateNumbers are not RawScalarValues from here https://github.com/handsontable/hyperformula/blob/fd0a40581d1dea2a19c2307228825ad0c3b6dedb/src/interpreter/CriterionFunctionCompute.ts#L160

AJNandi avatar Mar 29 '22 18:03 AJNandi

@AJNandi I'm sorry that you experience an issue with Hyperformula. I'll investigate this bug and come back with conclusions shortly.

sequba avatar Mar 31 '22 09:03 sequba

@AJNandi I can confirm it's a bug. It will be fixed in one of the upcoming releases.

sequba avatar Apr 06 '22 08:04 sequba

Hi @AJNandi

We just launched Hyperformula 2.1.0, where this issue is fixed. We are closing the issue as solved. If you would have any additional questions, please feel free to leave a comment.

AMBudnik avatar Sep 08 '22 12:09 AMBudnik