Skip to content

Instantly share code, notes, and snippets.

@HansPeterPfister
Created June 4, 2018 18:44
Show Gist options
  • Save HansPeterPfister/c13a3283cb54c87ea0402d9461066ba3 to your computer and use it in GitHub Desktop.
Save HansPeterPfister/c13a3283cb54c87ea0402d9461066ba3 to your computer and use it in GitHub Desktop.
// Code written by Hans Peter Pfister, www.powerbi-pro.com
let
Source = (Input as table) =>
let
Sorting = Table.Sort(Input,{{"Date", Order.Ascending}}), // Sort table
added_Index = Table.AddIndexColumn(Sorting, "Index", 1, 1), // add Index, base 1
cumulativ_total = Table.AddColumn( // add new column with running total
added_Index, "Total",
each List.Sum(
List.Range(added_Index[Amount],0,[Index])
)
),
extract_total = cumulativ_total[Total] // transform new column into list as result for grouping
in
extract_total
in
Source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment