Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sunil3M
New Member

SUMIF function

this is the formula i use in excel SUMIF($P$2:P17,P17,$AF$2:AF17)

want to replicae the same in power bi

can some one share me easy coding for the same

below is the data from excel and Order qty column is the column were i use this formula.

based on the SKU need to sum the value 

SKU #BACK QTYOrder Qty
IA110123493460460
IA11012349350005460
IA110123493500010460
IA110123493150011960
IA110123493200013960
IA11012349350014460
IA110123493160016060
IA110123493100017060
1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @sunil3M ,

 

Power query could also do it.

You could create an index column and a "RunningTotal" function in query editor.

= ( tbl as table,  sumcolumn as text, rowindex as number) =>
let
    #"Removed Columns" = Table.RemoveColumns(tbl,{"SKU #"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each [Index] <= rowindex),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{sumcolumn, "Temp"}}),
    #"Grouped Rows" = Table.Group(#"Renamed Columns", {}, {{"RunningTotal", each List.Sum([Temp]), type number}}),
    RunningTotal = Record.Field(#"Grouped Rows"{0},"RunningTotal")
in
    RunningTotal

Then use it to add a new column

=
Table.AddColumn(#"Removed Columns", "Custom", each TotalRunning(#"Removed Columns","BACK QTY",[Index]))

You could get more details from this link:

https://www.excelguru.ca/blog/2015/03/31/create-running-totals-in-power-query/

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

4 REPLIES 4
v-eachen-msft
Community Support
Community Support

Hi @sunil3M ,

 

Power query could also do it.

You could create an index column and a "RunningTotal" function in query editor.

= ( tbl as table,  sumcolumn as text, rowindex as number) =>
let
    #"Removed Columns" = Table.RemoveColumns(tbl,{"SKU #"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each [Index] <= rowindex),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{sumcolumn, "Temp"}}),
    #"Grouped Rows" = Table.Group(#"Renamed Columns", {}, {{"RunningTotal", each List.Sum([Temp]), type number}}),
    RunningTotal = Record.Field(#"Grouped Rows"{0},"RunningTotal")
in
    RunningTotal

Then use it to add a new column

=
Table.AddColumn(#"Removed Columns", "Custom", each TotalRunning(#"Removed Columns","BACK QTY",[Index]))

You could get more details from this link:

https://www.excelguru.ca/blog/2015/03/31/create-running-totals-in-power-query/

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
az38
Community Champion
Community Champion

@sunil3M 

first, create an Index column in Power Query then create a calculated column

Order Qty = 
CALCULATE(
SUM(Table[SKU #]), 
FILTER(ALL(Table), Table[SKU #] = EARLIER(Table[SKU #]) && Table[Index] <= EARLIER(Table[Index]))
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
sunil3M
New Member

 

image.png

az38
Community Champion
Community Champion

@sunil3M 

whats your desired output?

Its unclear as you didn't provide an excel example


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.