Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX

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 t...
  • Anonymous's avatar
    Anonymous
    4 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.