Forum Discussion

caito103's avatar
caito103
Helper I
9 years ago
Solved

Multiply two columns from different tables with a relationship

Hello, I have a few days working with PowerBI, and im here again asking for help. I need to multiply two columns ("Cantidad" per "Litros") from two differents tables, but this multiply have to be o...
  • v-qiuyu-msft's avatar
    9 years ago

    Hi caito103,

     

    Assume Producto and Cod.Producto has relationship n:1 (or 1:1) then you can create a relationship between those two tables based on Producto and Cod.Producto. See: Create and manage relationships in Power BI Desktop.

     

     

    Then create a measure like below:

    Measure = SUM(Table1[Cantidad])* SUM('Table2'[Litros])

     

    Another way is in Query Editor, use Merge Queries to merge those two tables to one table "Merged", see: Append vs. Merge in Power BI and Power Query, then create a measure  like below:

    Measure2 = SUM(Merged[Cantidad])* MAX('Merged'[Litros])

     

    Please see attached .pbix file.

     

    Best Regards,
    Qiuyun Yu