Forum

Running Totals - Th...
 
Notifications
Clear all

Running Totals - The Right Way!....how to duplicate code for multiple columns?

2 Posts
2 Users
0 Reactions
86 Views
(@francine88)
Posts: 1
New Member
Topic starter
 

Hi, I have successfully copied your code to create a Running Total for my report - thanks heaps 🙂

 

this is what I have....

BufferedValues = List.Buffer(#"Changed Type"[Total_Target]),

    RT = Table.FromList(fxRunning_Total(BufferedValues), Splitter.SplitByNothing(), {"RT"}),

    Columns = List.Combine({Table.ToColumns(#"Changed Type"), Table.ToColumns(RT)}),

    #"Converted to Table" = Table.FromColumns(Columns, List.Combine({Table.ColumnNames(#"Changed Type"), {"Running_Total"}})),

    #"Changed Type1" = Table.TransformColumnTypes(#"Converted to Table",{{"Running_Total", type number}}),

    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Running_Total", "Total_Target_Running_Total"}})

 

but now I need to duplicate this for a few more columns...at what part of the code to I need to copy & paste to add in new running total columns for RED & BLUE Targets?

Total_Target

RED_Target

BLUE_Target

Total_Target_Running_Total

RED_Target_Running_Total

BLUE_Target_Running_Total

 

 

 

 

 

 

 

 

 

 

 

 

many thanks,

Francine

 
Posted : 29/03/2024 1:02 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Francine,

You should convert all those steps into a function with 2 arguments: source table and total column name, will make things easy.

You upload a sample file if you need assistance on this.

 
Posted : 30/03/2024 4:15 am
Share: