library(tidyverse)
library(readxl)
path = "files/CH-111 iNCREASED SALES.xlsx"
input = read_excel(path, range = "B2:D25")
test = read_excel(path, range = "H2:H6")
result = input %>%
summarise(sales = sum(Sales), .by = Date) %>%
filter(sales > lag(sales)) %>%
select(Dates = Date)
identical(result, test)
# [1] TRUEOmid - Challenge 111
data-challenges
advanced-exercises
🔰 In the historical sales table, extract the dates where the total sales value is greater than the total on the previous date.

Challenge Description
🔰 In the historical sales table, extract the dates where the total sales value is greater than the total on the previous date.
Solutions
Logic:
Reads the workbook ranges needed for the challenge
Aggregates or ranks values at the relevant grouping level
Strengths:
- The R solution stays close to the workbook rule and keeps the transformation compact.
Areas for Improvement:
- The code assumes the sheet structure and source ranges remain stable.
Gem:
- The strongest part of the solution is choosing the right intermediate representation before shaping the final output.
import pandas as pd
path = "CH-111 iNCREASED SALES.xlsx"
input = pd.read_excel(path, usecols = "B:D", skiprows = 1, nrows = 24)
test = pd.read_excel(path, usecols = "H", skiprows = 1, nrows = 4)
result = input.groupby("Date").sum()
result = result[result["Sales"] > result["Sales"].shift(1)].reset_index()
result = result.drop(columns=["Sales", "Product"])
print(result["Date"].equals(test["Dates"])) # TrueLogic:
Reads the workbook ranges needed for the challenge
Aggregates or ranks values at the relevant grouping level
Strengths:
- The Python version follows the same rule in a direct dataframe-oriented implementation.
Areas for Improvement:
- The code assumes the workbook layout remains stable, so any sheet redesign would require small adjustments.
Gem:
- The implementation stays close to the original workbook rule instead of adding unnecessary abstraction.
Difficulty Level
This task is moderate:
- The business rule is readable, but the workbook still requires careful implementation to reach the expected layout.