library(tidyverse)
library(readxl)
path <- "Power Query/300-399/361/PQ_Challenge_361.xlsx"
input <- read_excel(path, sheet = "Sheet1", range = "A1:A21")
test <- read_excel(path, sheet = "Sheet1", range = "C1:F6")
pattern <- "#(?<TicketID>\\d+-\\d+)#\\s*\\((?<Priority>[A-Z]+)\\)\\s*Service:(?<Service>[^>]+)\\s>>\\s*(?<Status>\\w+)"
result = input %>%
mutate(`Log Data` = str_remove_all(`Log Data`, "Status:"))
result = str_match(result$`Log Data`, pattern) %>%
as_tibble() %>%
select(-V1) %>%
filter(!Status %in% c("Resolved", "Closed"))
all.equal(result, test, check.attributes = FALSE)
# TRUEExcel BI - PowerQuery Challenge 361
excel-challenges
power-query
Extract Ticket_ID, Priority, Service & Status and list only those tickets whose status is neither Resolved nor Closed.

Challenge Description
Extract Ticket_ID, Priority, Service & Status and list only those tickets whose status is neither Resolved nor Closed.
Solutions
Logic:
Reads the workbook range needed for the challenge
Builds helper columns that drive the final output
Uses direct pattern parsing where the workbook encodes logic in text
Strengths:
- The R solution stays close to the workbook logic and keeps the transformation compact.
Areas for Improvement:
- The code assumes the workbook layout and selected ranges remain stable.
Gem:
- The best part of the solution is choosing the right intermediate shape before formatting the final output.
import pandas as pd
path = "Power Query/300-399/361/PQ_Challenge_361.xlsx"
input_data = pd.read_excel(path, sheet_name="Sheet1", usecols="A", nrows=21)
test = pd.read_excel(path, sheet_name="Sheet1", usecols="C:F", nrows=5)
result = (
input_data['Log Data']
.str.replace('Status:', '', regex=False)
.str.extract(
r'#(?P<Ticket_ID>\d+-\d+)#\s*'
r'\((?P<Priority>[A-Z]+)\)\s*'
r'Service:(?P<Service>[^>]+?)'
r'\s*>>\s*'
r'(?P<Status>\w+)'
)
.assign(Service=lambda x: x['Service'].str.strip())
.query("Status != 'Closed' and Status != 'Resolved'")
.reset_index(drop=True)
)
print(result.equals(test)) # TrueLogic:
Reads the workbook range needed for the challenge
Builds helper columns that drive the final output
Uses direct pattern parsing where the workbook encodes logic in text
Strengths:
- The Python version follows the same workbook rule in a direct pandas-oriented implementation.
Areas for Improvement:
- As with the R version, any workbook layout change would require small adjustments.
Gem:
- The implementation stays close to the source challenge instead of adding unnecessary abstraction.
Difficulty Level
This task is moderate:
It combines reshaping, grouping, or parsing steps that are common in Power Query style problems.
The main challenge is reproducing the workbook output structure exactly.