Forum Discussion
Row context total of previous rows
- Anonymous7 years ago
Solved it myself ;), and want to share it, if in any case there is an easier way to do this, im still interested.
My calculated column formula is as follows:
'New column' =
CALCULATE ( SUM ( Table1[Amount] ); ALLEXCEPT ( Table1; Table1[Key] ) )
- DATEDIFF (
Table1[Date];
CALCULATE ( MAX ( Table1[Date] ); ALLEXCEPT ( Table1; Table1[Key] ) );
DAY
) - 7 years ago
Hi,
This M code (Query Editor) will also work
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Key", type text}, {"Date", type datetime}, {"Amount", Int64.Type}}), Partition = Table.Group(#"Changed Type", {"Key"}, {{"Partition", each Table.AddIndexColumn(_, "Index",1,1), type table}}), #"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"Date", "Amount", "Index"}, {"Date", "Amount", "Index"}) in #"Expanded Partition"Hope this helps.
Solved it myself ;), and want to share it, if in any case there is an easier way to do this, im still interested.
My calculated column formula is as follows:
'New column' =
CALCULATE ( SUM ( Table1[Amount] ); ALLEXCEPT ( Table1; Table1[Key] ) )
- DATEDIFF (
Table1[Date];
CALCULATE ( MAX ( Table1[Date] ); ALLEXCEPT ( Table1; Table1[Key] ) );
DAY
)
Hi Anonymous ,
It's pleasant that your problem has been solved, could you please mark one reply as Answered to close this topic?
Regards,
Daniel He