Forum Discussion
DAX
- Anonymous4 years ago
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})