library(tidyverse)
library(readxl)
path = "Excel/700-799/743/743 Amount Distribution.xlsx"
input = read_excel(path, range = "A2:C7")
test = read_excel(path, range = "E2:Q7") %>%
arrange(Name)
calendar = expand.grid(
Name = input$Name,
Month = factor(month.abb, levels = month.abb, ordered = TRUE, labels = month.abb)
)
result = input %>%
separate_longer_delim(Months, delim = ", ") %>%
mutate(Month= month(as.numeric(Months), label = TRUE, abbr = TRUE, locale = "en_US.UTF-8"))
r2 = result %>%
full_join(calendar, by = c("Name", "Month")) %>%
arrange(Name, Month) %>%
mutate(non_zero_months = sum(ifelse(is.na(Amount), 0, 1)),
per_month_amount = ifelse(is.na(Amount), 0, Amount / non_zero_months),
.by = Name) %>%
select(Name, per_month_amount, Month) %>%
pivot_wider(names_from = Month, values_from = per_month_amount)
all.equal(r2, test, check.attributes = FALSE)
# [1] TRUEExcel BI - Excel Challenge 743
excel-challenges
excel-formulas
🔰 Answer Expected Name Months Amount Jan Feb Mar Apr May Jun

Challenge Description
🔰 Answer Expected Name Months Amount Jan Feb Mar Apr May Jun
Solutions
- Logic: Read the workbook ranges needed for the challenge; Derive the required intermediate columns; Parse the packed text or string structure; Aggregate or rank the data at the required grouping level.
- Strengths: The reshaping step mirrors the workbook output closely instead of forcing extra post-processing.
- 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 last reshape turns a raw transformation into something that already looks like a report.
import pandas as pd
import numpy as np
from calendar import month_abbr
path = "700-799/743/743 Amount Distribution.xlsx"
input = pd.read_excel(path, usecols="A:C", skiprows=1, nrows=5)
test = (pd.read_excel(path, usecols="E:Q", skiprows=1, nrows=5)
.rename(columns=lambda col: str(col).replace('.1', ''))
.sort_values(by="Name")
.reset_index(drop=True))
month_abbrs = list(month_abbr)[1:]
result = (input.assign(Months=input["Months"].str.split(", "))
.explode("Months")
.assign(Month=lambda x: pd.to_datetime(x["Months"].astype(int), format="%m").dt.strftime("%b")))
names_months = pd.DataFrame([(name, month) for name in input["Name"] for month in month_abbrs],
columns=["Name", "Month"])
r2 = (names_months.merge(result[["Name", "Month", "Amount"]], on=["Name", "Month"], how="left")
.assign(
non_zero_months=lambda x: x.groupby("Name")["Amount"].transform("count"),
per_month_amount=lambda x: x["Amount"].fillna(0).div(x["non_zero_months"]).astype(int)
)
.pivot(index="Name", columns="Month", values="per_month_amount")
.reindex(columns=month_abbrs)
.reset_index())
print(r2.equals(test)) # TrueThe Python version follows the same grouped logic and keeps the transformation explicit in a dataframe pipeline.
Difficulty Level
Medium
The individual steps are manageable, but the correct transformation pattern is not obvious from the raw data.