Excel BI - Excel Challenge 706

excel-challenges
excel-formulas
🔰 Find the running total of Odd and Even numbers separately.
Published

March 24, 2026

Illustration for Excel BI - Excel Challenge 706

Challenge Description

🔰 Find the running total of Odd and Even numbers separately.

Solutions

library(tidyverse)
library(readxl)

path = "Excel/706 Running Total for Even & Odd.xlsx"
input = read_excel(path, range = "A1:A30")
test = read_excel(path, range = "B1:B30")

result = input %>%
  mutate(odd_even = ifelse(Numbers %% 2 == 0, "even", "odd")) %>%
  mutate(result = cumsum(Numbers), .by = odd_even) %>%
  select(-odd_even)

all.equal(result$result, test$`Answer Expected`)
# [1] TRUE
  • Logic: Read the workbook ranges needed for the challenge; Derive the required intermediate columns; Aggregate or rank the data at the required grouping level; Apply the business rule conditions explicitly.
  • Strengths: The code maps the workbook rule into a compact, reproducible pipeline.
  • Areas for Improvement: The solution assumes the workbook layout and selected ranges remain stable, so any structural change in the sheet would require small adjustments.
  • Gem: The elegant part is how little code is needed once the correct intermediate representation is chosen.
import pandas as pd

path = "706 Running Total for Even & Odd.xlsx"

input = pd.read_excel(path, usecols="A", nrows=30)
test = pd.read_excel(path, usecols="B", nrows=30)

input['result'] = input.groupby(input['Numbers'] % 2)['Numbers'].cumsum()

print(input["result"].equals(test["Answer Expected"])) # True

The Python version follows the same grouped logic and keeps the transformation explicit in a dataframe pipeline.

Difficulty Level

Easy / Medium

The business rule is clear, though the workbook still needs a few transformation steps to reach the expected output.