Search code examples
powerbipowerquery

How to join columns from different tables and insert a calculated column in PowerBI / Power Query


I have 2 tables in Power BI: ITEMS and SUB_ITEMS.

  • ITEMS is a table of actions to be performed.

  • SUB_ITEMS is a table of sub actions to be performed, regarding to the main action.

  • ITEMS has 15 rows.

  • SUB_ITEMS has 70 rows.

Each action in SUB_ITEMS has a percentage of completion:

  • sub action 1) 100%
  • sub action 2) 0%
  • sub action 3) 0%
  • sub action 4) 20%
  • sub action 5) 20%

In this case, the total progress of the main action (ITEMS) should be 28%:

  • sub action 1) 100% of 20% = 20%
  • sub action 2) 0% of 20% = 0%
  • sub action 3) 0% of 20% = 0%
  • sub action 4) 20% of 20% = 4%
  • sub action 5) 20% of 20% = 4%
  • total progress) 20% + 0% + 0% + 4% + 4% = 28%

I created a calculated table that gives me the percentage for each action (eg. 20%).

The percentage for each sub action is already in the table SUB_ITEMS (eg. 100%, 0%, 0%, 20%, 20%).

I need to put the column ITEM_NUMER, from ITEMS, together with SUB_ITEM_NUMBER into a new table, in order to apply the percentage from ITEMS (eg. 20%) over each percentage from the SUB_ITEMS (eg. 100%, 0%, 0%, 20%, 20%).

I don't know how to apply this percentage, once that the measure created to bring the 20% percentage is not available in Power Query, only in Power BI.

I'd appreciate your help.

Thanks in advance.


Solution

  • Assuming your data looks like this in Powerquery

    enter image description here

    Then in the ITEMS table, add column .. custom column .. with formula

     = [Percent]*List.Sum(SUB_ITEMS[Percent])