Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INDEX function discrepancy #127

Open
MrFoote opened this issue Feb 4, 2024 · 0 comments
Open

INDEX function discrepancy #127

MrFoote opened this issue Feb 4, 2024 · 0 comments

Comments

@MrFoote
Copy link

MrFoote commented Feb 4, 2024

Describe the bug
The INDEX() function does not behave like in Excel, specifically for the case where col = 0 i.e. when it should take the full column. Summing over an INDEX() goes wrong.

To Reproduce

# Excel file 'python_formulas_index_bug.xlsx' as below (sheet name: Sheet1)

#   A   B   C
#1  1   4   7
#2  2   5   8
#3  3   6   9

# E2 = 2
# E3 =SUM(INDEX(A2:C4;0;E2))

# Instruction:
# Compile a python formulas function with E2 as input and E3 as output 
# Excel returns E3 value = 15, i.e. the sum of the 2nd column in the A2:C4 range, as expected. Formulas returns 4 = the first value in the (correct) column of the range. This is incorrect.

# Code to reproduce error
import formulas
filepath = 'python_formulas_index_bug.xlsx'
xl_model = formulas.ExcelModel().loads(filepath).finish()
excel_inputs  = ["'[python_formulas_index_bug.xlsx]SHEET1'!E2"]
excel_outputs = ["'[python_formulas_index_bug.xlsx]SHEET1'!E3"]
func = xl_model.compile(inputs = excel_inputs, outputs = excel_outputs)
func(2) # Expected 15, get 4

image

Desktop (please complete the following information):

  • OS: macOS
  • Version 14.2.1 (23C71)

Additional context
Hey! Formulas is an awesome library. I was looking at the INDEX() implementation to see if I could figure out the problem, but I didn't get anywhere. Really appreciate your work, thank you! Sincerely /Christoffer Jevring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant