Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Merging and pivoting two tables

Please can someone help me to create a clustered bar chart using data from two tables. The ‘GTR’ table looks like this:

GTR Table

Name

C4L MB

C4L MLE

Craig

1

2

John

3

4

 

The second table ‘LW’ looks like this:

LW Table

Name

C4L MB

C4L MLE

Craig

1

1

Craig

2

3

John

3

2

John

4

4

 

I think that I need to create a table in Power BI that looks like this:

Name

Rubric

GTR Score

LW Score (=Average of ‘LW’ score for that individual and column)

Craig

“C4L MB”

1

1.5

Craig

“C4L MLE”

2

2

John

“C4L MB”

3

3.5

John

“C4L MLE”

4

3

 

So that I can then create a clustered bar chart that is filtered for Craig or John that look like these:

Bar chart for CraigBar chart for CraigBar chart for JohnBar chart for John

 
 

Your assistance would be much appreciated.

 

Thanks Steve

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

Add one static column to each table, prefer to add custom in edit query

Type = GTR

TYPE = GW

Then use unpivot: https://radacad.com/pivot-and-unpivot-with-power-bi

Then append data: https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Now you can use filter in formula and take avg or min max

calculate(Avg(Table[Score]),Table[Type]="GW")

 

I assumed score is the column, where numeric data moved

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on my research, you may click 'Edit Query', go to Query Editor, right-click GTR table and choose 'duplicate'.
d1.png

 

Then you can make 'C4L MB' and 'C4L MLE' selected, go to 'Transform' ribbon, click 'unpivot columns', rename the columns and click 'Close and Apply' in 'Home' ribbon.

d2.png

d3.png

 

Then you may create a measure as follows.

 

LW Score = 

IF(
    MAX('GTR Table (2)'[Rubric]) = "C4L MB",
    CALCULATE(
        AVERAGE('LW Table'[C4L MB]),
        FILTER(
            ALLSELECTED('LW Table'),
            'LW Table'[Name] = MAX('GTR Table (2)'[Name])
        )
    ),
    IF(
        MAX('GTR Table (2)'[Rubric]) = "C4L MLE",
        CALCULATE(
            AVERAGE('LW Table'[C4L MLE]),
            FILTER(
                ALLSELECTED('LW Table'),
                'LW Table'[Name] = MAX('GTR Table (2)'[Name])
            )
        )
    )
)
    

 

 

Result:

d4.png

d5.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , If the above solutions worked out for you ?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on my research, you may click 'Edit Query', go to Query Editor, right-click GTR table and choose 'duplicate'.
d1.png

 

Then you can make 'C4L MB' and 'C4L MLE' selected, go to 'Transform' ribbon, click 'unpivot columns', rename the columns and click 'Close and Apply' in 'Home' ribbon.

d2.png

d3.png

 

Then you may create a measure as follows.

 

LW Score = 

IF(
    MAX('GTR Table (2)'[Rubric]) = "C4L MB",
    CALCULATE(
        AVERAGE('LW Table'[C4L MB]),
        FILTER(
            ALLSELECTED('LW Table'),
            'LW Table'[Name] = MAX('GTR Table (2)'[Name])
        )
    ),
    IF(
        MAX('GTR Table (2)'[Rubric]) = "C4L MLE",
        CALCULATE(
            AVERAGE('LW Table'[C4L MLE]),
            FILTER(
                ALLSELECTED('LW Table'),
                'LW Table'[Name] = MAX('GTR Table (2)'[Name])
            )
        )
    )
)
    

 

 

Result:

d4.png

d5.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks for your help as well. I needed some of your response as well to get to a solution.

 

Steve

amitchandak
Super User
Super User

Add one static column to each table, prefer to add custom in edit query

Type = GTR

TYPE = GW

Then use unpivot: https://radacad.com/pivot-and-unpivot-with-power-bi

Then append data: https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Now you can use filter in formula and take avg or min max

calculate(Avg(Table[Score]),Table[Type]="GW")

 

I assumed score is the column, where numeric data moved

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks very much, I used the Unpivot and Append elements of your answer - which were much appreciated, but there were some elements that didn't take me in the right direction.

 

Steve

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.