Search code examples
libreoffice-calclibreoffice-basic

Get a conditional result


Adding detail. I have a spreadsheet like this:

B           C       D       E       F   G           H   
Date        Time    Kwh $/KwCost        Hours/MonthsCost/Kwh
2021-01-01  0:15    0.69    $0.00   0   months      $0.15
2021-01-01  0:30    0.51    $0.00   0   11-12,1-5   $0.05
01/08/21    0:45    0.3     $0.00   0   hours   
2021-01-01  1:00    0.76    $0.00   0   06-08,15-20 ```

The rules: if the month # is in g3 and the hour# is in g5 then $h$2.

I am using

=iF (LSTOR(MONTH(c2),$h$3)= MONTH(c2)) and (LSTOR(HOUR(d2),$h$5)=HOUR(d2)) then $i$2 else $i$3

but I am getting

509 Missing operator Operator is missing, for example, "=2(3+4) * ", where the operator between "2" and "(" is missing.)

Can someone show me where the error is?


Solution

  • Considering that all functions in this version of the ListOK add-in work with positive integers (except zero), you must specify values in the G5 shift ranges, 7-9,16-21 instead of 06-08,15-20. In this case, the formula

    =IF(OR(LSTOR(MONTH(B2);$G$3)="";LSTOR(HOUR(C2)+1;$G$5)="");$J$3;$J$2)
    

    should give you the desired result.