Crispo - Excel Challenge 43 2024

excel-challenges
weekly-exercises
Easy Sunday Excel Challenge
Published

October 27, 2024

Illustration for Crispo - Excel Challenge 43 2024

Challenge Description

Easy Sunday Excel Challenge

⭐ Date Staff Sales Besakoa Rick Jo

Solutions

library(tidyverse)
library(readxl)

path = "files/Excel Challenge October 27th.xlsx"
input = read_excel(path, range = "C3:E21")
test  = read_excel(path, range = "G3:H7") %>% na.omit() %>% mutate(Date = as.Date(Date))
threshold = 800

result = input %>%
  group_by(Staff) %>%
  filter(cumsum(Sales) >= threshold) %>%
  slice(1) %>%
  mutate(Date = as.Date(Date)) %>%
  select(Staff, Date) %>%
  arrange(Date)

all.equal(result, test, check.attributes = FALSE)
  • Logic:

    • Reads the workbook range needed for the challenge

    • Aggregates or ranks values at the correct grouping level

    • Builds the intermediate helper columns that drive the final answer

  • Strengths:

    • The R solution stays compact and mirrors the workbook logic closely.
  • Areas for Improvement:

    • The code assumes the workbook layout and named ranges remain stable.
  • Gem:

    • The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd

path = "files/Excel Challenge October 27th.xlsx"
input = pd.read_excel(path, usecols="C:E", skiprows=2, nrows=19)
test = pd.read_excel(path, usecols="G:H", skiprows=2, nrows=5).dropna().rename(columns=lambda x: x.replace('.1', ''))
test['Date'] = pd.to_datetime(test['Date'])

threshold = 800

result = (input[input.groupby('Staff')['Sales'].cumsum() >= threshold]
          .drop_duplicates('Staff')
          .assign(Date=lambda df: pd.to_datetime(df['Date']))
          .loc[:, ['Staff', 'Date']]
          .sort_values(by='Date')
          .reset_index(drop=True))

print(result.equals(test)) # True
  • Logic:

    • Reads the workbook range needed for the challenge

    • Aggregates or ranks values at the correct grouping level

    • Builds the intermediate helper columns that drive the final answer

  • Strengths:

    • The Python version keeps the same rule in a direct pandas-oriented workflow.
  • Areas for Improvement:

    • As with the R version, any workbook layout change would require small adjustments.
  • Gem:

    • The implementation stays close to the stated challenge instead of adding unnecessary complexity.

Difficulty Level

This task is moderate:

  • It combines familiar Excel-style logic with at least one non-trivial reshape, grouping, or parsing step.

  • The answer depends on getting the output layout exactly right.