0

I'm facing a challenge in power bi where I need to join Table 1 & Table 2 but the catch is Table 2 needs to be pivoted before joining.

Input: Table 1 enter image description here

Table 2 enter image description here

Expected Output: enter image description here

How to build the output table when the Table 2 rows will be increasing daily

2 Answers 2

1

Your desired result needs a combination of Unpivot, Merge and Pivot steps.

You can follow the following steps:

  1. Convert the Date column to Text type.
  2. Unpivot columns Sales in KG & Sales in Amount from Table 2 - it will create 2 columns called Attribute & Value
  3. Merge columns Date & Attribute to create a new column (lets call it columnHeaders) - this will be in the format - 1/3/22 Sales in KG, 1/3/22 Sales in Amount ...
  4. Merge Table 1 into Table 2 and expand the Product Name column
    • Now you will have 4 columns - Product Code, columnHeaders, Value, & Product Name
  5. Pivot columnHeader using the Value column for values

You should have your desired result.

Sign up to request clarification or add additional context in comments.

Comments

0

I dont know why you try to unpivot your table. Just use a Matrix visualization:

Model relationship: enter image description here Imput data + output: enter image description here enter image description here

sum of kg = CALCULATE(sum(Table2[Sales in kg]))

1 Comment

I’m trying to un pivot because I need add furthermore calculation - weekly return, weekly growth & group products and then show it in visualisation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.