Search code examples
bigdatapowerbibusiness-intelligencedax

Add Columns in PowerBI programmatically


I have a List of raw material orders for each Month & each product and want to add columns programmatically to an new Table in PowerBI. In every programming Language i would just write a quick loop, but in this case i don't know how to do it in DAX.

My Data Format

Month    | Name      | Amount | Price
-----------------------------------
Jan   18 | Product 1 | 1000   | 1200€
March 18 | Product 1 | 1100   | 1400€
Feb   18 | Product 1 | 1000   | 1200€
Jan   18 | Product 2 | 400    | 600€
Feb   18 | Product 2 | 1000   | 1200€
March 18 | Product 2 | 100    | 100€
April 18 | Product 2 | 1000   | 1200€

My desired output Format

Month    | Product 1 | Product 2
---------------------------------
Jan   18 | 1200€     | 600€    
Feb   18 | 1200€     | 1200€
March 18 | 1400€     | 100€
April 18 | 0€        | 1200€

Solution

  • You can do this in the query editor by removing the Amount column and pivoting on the Name column with Price as the values column.