Excel BI - Excel Challenge 833

excel-challenges
excel-formulas
🔰 Summarize the table as shown where Amount is sum of non date values from Data Column.
Published

March 24, 2026

Illustration for Excel BI - Excel Challenge 833

Challenge Description

🔰 Summarize the table as shown where Amount is sum of non date values from Data Column.

Solutions

library(tidyverse)
library(readxl)

path = "Excel/800-899/833/833 Summarize.xlsx"
input = read_excel(path, range = "A2:C14")
test  = read_excel(path, range = "E2:H5")

result = input %>%
  mutate(Date = ifelse(!is.na(Task), Data, NA)) %>%
  fill(Date, Task) %>%
  filter(Data != Date) %>%
  summarise(Amount = sum(Data, na.rm = TRUE), .by = c(Store, Date, Task)) %>%
  mutate(Date = janitor::excel_numeric_to_date(Date) %>% as.POSIXct())

all.equal(result, test, check.attributes = FALSE)
# [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 = "800-899/833/833 Summarize.xlsx"
input = pd.read_excel(path, usecols="A:C", skiprows=1, nrows=13)
test = pd.read_excel(path, usecols="E:H", skiprows=1, nrows=3).rename(columns=lambda col: col.replace('.1', ''))

input['Date'] = input.apply(lambda row: row['Data'] if pd.notna(row['Task']) else pd.NA, axis=1)
input['Date'] = input['Date'].fillna(method='ffill')
input['Task'] = input['Task'].fillna(method='ffill')
filtered = input[input['Data'] != input['Date']]

result = (
    filtered
    .groupby(['Store', 'Date', 'Task'], as_index=False)
    .agg(Amount=('Data', lambda x: x.sum(skipna=True)))
)
print(result.equals(test)) # 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.