I have generated an Excel file, with the following columns (cf. minimal code below):
- ID (col. A): set via hardcoded values (i.e. not via Excel formula)
- Manually-set resolved (col. B): a column that should either be left blank or set
TRUEby the user - Resolved (col. D): a column indicating whether "something" (represented by the row) has been "resolved"; it should be
TRUEiff:- Manually-set resolved is
TRUE - and/or Any in ID resolved (see directly below) is
TRUE
- Manually-set resolved is
- Any in ID resolved (col. C): a column indicating whether any of the rows sharing the ID value have Resolved equal
TRUE
Formulas are OR-based for column Resolved, MAXIFS-based for column Any in ID resolved (cf. minimal code below).
Example formulas (note: German locale for installed Excel - does not matter; English formula names are recognized):
- Resolved cell:
D2=ODER(B2=WAHR;C2=WAHR) - Any in ID resolved cell:
C2=@MAXIFS($D$2:$D$11;$A$2:$A$11;A2)
Issue:
I would expect that at the beginning both the columns Resolved and Any in ID resolved are all FALSE and that values are auto-set by the formulas to TRUE as soon as the user sets the column Manually-set resolved to TRUE.
Unfortunately, that is not what happens - rather, when opening the generated Excel file, the cells all display #NAME? (cf. screenshot below), as if there was an issue with the formulas - but I cannot figure out what it is. And sometimes, when fiddling around with the generated Excel, 0 is displayed (which can be seen as representing FALSE) - but then column Resolved does not auto-update when Manually-set resolved is set to TRUE.
Notes:
- Excel 365 is used - version 2502, so
MAXIFScan be used (is available) - Excel also warns about circularity - and yes, the columns Resolved and Any in ID resolved refer to each other - but it should NOT be an issue, since Manually-set resolved should break any such circularity issues via first setting Resolved to
TRUEand based on that Any in ID resolved toTRUE.
Questions:
- Why do the Resolved and Any in ID resolved columns display
#NAME?rather thanFALSE? - Why does the Resolved column not auto-update when the Manually-set resolved column is set to
TRUE?
Minimal example code to generate a test Excel file:
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws.title = "Example"
# Column headers
ws['A1'] = "ID"
ws['B1'] = "MANUALLY_SET_RESOLVED"
ws['C1'] = "ANY_IN_ID_RESOLVED"
ws['D1'] = "RESOLVED"
num_rows = 10
# Populate example data for ID (e.g. 3 groups: 1,2,3 repeated)
for row in range(2, num_rows + 2):
ws[f"A{row}"] = (row - 2) % 3 + 1 # Cycle through 1,2,3
# MANUALLY_SET_RESOLVED starts empty (FALSE/blank)
ws[f"B{row}"] = None
# ANY_IN_ID_RESOLVED: MAXIFS over RESOLVED column for group
ws[f"C{row}"].value = f'=MAXIFS($D$2:$D${num_rows + 1},$A$2:$A${num_rows + 1},A{row})'
# RESOLVED: OR of MANUALLY_SET_RESOLVED and ANY_IN_ID_RESOLVED
ws[f"D{row}"].value = f'=OR(B{row}=TRUE,C{row}=TRUE)'
wb.save("example_file.xlsx")
Update for @MGonet:
The MAXIFS appears to have issues somehow even with numbers rather than booleans - see this screenshot:
But when using MAXWENNS instead, the formula returns a result - not the correct one though, since it will always return 0 for any booleans (even TRUE). This indicates that there might be a localization issue, and that booleans might need to be converted to numbers via -- inside the formula:
Also, in such a case, without overwriting the Resolved column manually with booleans, MAXWENNS returns 0, Excel displays circularity warnings and also visualizes that via a blue-red double arrow (cf. screenshot), and setting Manually-set resolved to TRUE does NOT update Resolved - which it should, however.
Then, only when double-clicking into a Resolved cell (but I want auto-re-calculation) and pressing Enter, is the value set - to 0 - which is incorrect, since it should be TRUE. I do actually not understand how =OR(TRUE;0) returns 0 rather than TRUE - that makes no sense to me. Apart from that returning 0 for =NOT(0) is also plain wrong:





