Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hi everyone,
I'm experiencing a problem with my data. I have the table 'Outbound' which has Delivery, Freight Costs, Sales and Date fields.
I want to manipulate the Freight Costs column according to Delivery Field.
What I have
Delivery Freight Sales
S102 $30 $300
S102 $30 $400
S103 $50 $500
What I want
Delivery Freight Sales
S102 $0 $300
S102 $30 $400
S103 $50 $500
Please note that I don't want to sum duplicates for the delivery, I want to write one of the duplicate values in freight costs for that particular delivery and make the other one 0 to ensure that the total sum of the column is accurate. Thanks for your help in advance.
Solved! Go to Solution.
Hi @Anonymous ,
This is the Power Query forum. In the Power Query Editor, we use the M language instead of the DAX language. There is a difference between the two. You can check this blog for reference.
My solution is completed in Power Query Editor.
Sample data
1.Select both columns and group by.
2.Select All Rows and click ok.
You get this.
3.Add a custom column.
Table.AddIndexColumn([Count],"Index",1)
4.Expand the Sales column and the Index column, remove the Count column.
5.Add a conditional column, set if [Index] = 1 then [Freight] else 0.
6.Remove the unneeded columns and rename the custom column. Finally get the result.
You can download the .pbix to check.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
This is the Power Query forum. In the Power Query Editor, we use the M language instead of the DAX language. There is a difference between the two. You can check this blog for reference.
My solution is completed in Power Query Editor.
Sample data
1.Select both columns and group by.
2.Select All Rows and click ok.
You get this.
3.Add a custom column.
Table.AddIndexColumn([Count],"Index",1)
4.Expand the Sales column and the Index column, remove the Count column.
5.Add a conditional column, set if [Index] = 1 then [Freight] else 0.
6.Remove the unneeded columns and rename the custom column. Finally get the result.
You can download the .pbix to check.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
NewStep=Table.FromRecords(List.Accumulate(Table.ToRecords(PreviousStepName),{},(x,y)=>if x={} then {{y},Record.AddField([],y[Delivery],0)} else {x{0}&{y&[Freight=Record.FieldOrDefault(x{1},y[Delivery],1)*y[Freight]]},x{1}&Record.AddField([],y[Delivery],0)}){0})
Hi,
If you are only concerned about the sum of the rows you can use this as an alternate way of achieving your goal:
Example data:
1st I created a duplicate query and grouped it:
#"Grouped Rows" = Table.Group(#"Changed Type", {"Delivery"}, {{"Count", each Table.RowCount(_), Int64.Type}})
After this I merged this count to the original:
Now Simply divide the original value with the count to get a row specific value:
Full M:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjY0MFLSUTI2ABMGSrE6qGImCDFjINfUAEwAxWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Delivery = _t, Value = _t, Sales = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Delivery", type text}, {"Value", Int64.Type}, {"Sales", Int64.Type}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Delivery"}, #"DeliveryPQ Grouped", {"Delivery"}, "DeliveryPQ Grouped", JoinKind.LeftOuter),
#"Expanded DeliveryPQ Grouped" = Table.ExpandTableColumn(#"Merged Queries", "DeliveryPQ Grouped", {"Count"}, {"Count"}),
#"Added Custom" = Table.AddColumn(#"Expanded DeliveryPQ Grouped", "NewValue", each [Value]/[Count]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Value", "Count"})
in
#"Removed Columns"
Maybe you can solve your issue by using this method?
Proud to be a Super User!
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 5 | |
| 5 | |
| 4 |