Skip to content

Instantly share code, notes, and snippets.

View cbaragao's full-sized avatar

Chris Aragao cbaragao

View GitHub Profile
@cbaragao
cbaragao / ExcelChallenge1043.pq
Created August 14, 2026 23:59
Excel Challenge 1043
let
Source = Excel.CurrentWorkbook(){[Name = "Data"]}[Content],
#"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type),
#"Duplicated Column" = Table.DuplicateColumn(#"Added Index", "Data", "Data - Copy"),
#"Changed Type" = Table.TransformColumnTypes(
#"Duplicated Column",
{{"Data", type text}, {"Data - Copy", type text}}
),
#"Split Column by Space" = Table.ExpandListColumn(
Table.TransformColumns(
@cbaragao
cbaragao / ExcelChallenge1040.pq
Created August 13, 2026 00:49
ExcelChallenge1040
let
Source = Excel.CurrentWorkbook(){[Name = "Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(
Source,
{{"Sequence", type text}, {"Target", Int64.Type}}
),
AddedNestedList = Table.AddColumn(
#"Changed Type",
"List1",
each
@cbaragao
cbaragao / ExcelChallenge1041.pq
Created August 12, 2026 23:55
ExcelChallenge1041
let
Source = Excel.CurrentWorkbook(){[Name = "Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source, {{"Data", type text}}),
Tx = Table.TransformColumns(
#"Changed Type",
{
"Data",
each [
Category = Text.Trim(Text.Split(_, ">"){0}),
Transaction = Text.Trim(List.Last(List.RemoveLastN(Text.Split(_, ":"), 1))),
@cbaragao
cbaragao / ExcelChallenge1038.pq
Created August 7, 2026 21:21
Excel Challenge 1038
let
Source = Excel.CurrentWorkbook(){[Name = "Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source, {{"Data", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(
#"Changed Type",
"Data",
Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv),
{"Data.1", "Data.2", "Data.3", "Data.4"}
),
#"Changed Type After Split" = Table.TransformColumnTypes(
@cbaragao
cbaragao / ExcelChallenge1037.pq
Created August 7, 2026 02:45
Excel Challenge 1037
let
Source = Excel.CurrentWorkbook(){[Name = "Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source, {{"Data", type text}}),
Base = Table.AddColumn(
#"Changed Type",
@cbaragao
cbaragao / Select-Case.pq
Created August 5, 2026 02:30
Select-Case function for Power Query
let
SelectCase = (value as any, l as list, default as any) as any =>
let
// Function to select nth item of list
// If you pass in zero, you get even indices (predicates)
// If you pass in one, you get odd indices (results)
fnSelectEvenOdd = (lst as list, remainder as number) as list =>
let
result = List.Select(
lst,
@cbaragao
cbaragao / Prompter.ontm
Created May 15, 2026 00:39
A prompt form for OneNote using OneTastic
function Main($arg, $context)
$prompter = DialogBox_Create("")
DialogBox_AddLabel($prompter, "1 - Objective")
DialogBox_AddLabel($prompter, " ")
DialogBox_AddTextBox($prompter, "&Task", "Task", "", false)
DialogBox_AddDropDown($prompter, "&Output format", "OutputFormat", "Prose", Array("Prose", "Bullet list", "Numbered list", "Table", "JSON", "Code", "Step-by-step"))
DialogBox_AddDropDown($prompter, "&Length target", "LengthTarget", "Concise", Array("Very short", "Concise", "Medium", "Long"))
// Function to calculate the distance between two geographic coordinates
GetDistance(lat1:Number, lon1:Number, lat2:Number, lon2:Number):Number = With(
{
// Convert latitude and longitude differences from degrees to radians
dLat: (lat2 - lat1) * Pi() / 180.0,
dLon: (lon2 - lon1) * Pi() / 180.0,
// Convert original latitudes to radians
(l as list, selections as list)=>
let
Source =
List.Accumulate(
selections,
{},
(state,current)=>
if
Text.Contains(current,":")
then
(l as list, range as list)=>
let
Start_Position = List.PositionOf(l, range{0}),
End_Position = List.PositionOf(l, range{1}),
Result= List.Range(l,Start_Position,(End_Position-Start_Position)+1)
in
Result