Forum Discussion

skdh_01's avatar
skdh_01
Frequent Visitor
2 years ago
Solved

How to calculate with data across multiple tables

Hi PBI Community,   I have a few tables queried from SQL DB (with those necessary columns extracted below) and I need to create various visuals calculating the order_quantity / charge_amount based ...
  • marcosvin's avatar
    marcosvin
    2 years ago

    Hello!

     

    Exactly, in theory, the closer to the data source you make the transformations to organize the data, the better the performance can be (of course, it is important to test to validate).

     

    For example, a SQL query to join the columns of the "order_table" table with the "order_sub_table" table would look like this:

     

    SELECT ot.order_date,ot.order_no,ot.shipper_code,ot.consignee_code,ost.order_quantity,ost.comm_type
    FROM order_table ot
    LEFT JOIN order_sub_table ost
    ON ot.order_no = ost.order_no

     

    In Power BI Desktop, when importing data from a database, in "Advanced options" a "SQL Statement" text box appears for you to paste your SQL query, like the query above. This step would be important to avoid carrying out many merge operations within Power BI Desktop, and the organization into fact and dimension tables would be important to facilitate the creation of metrics and relationships between tables.