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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Multiply two or more tables

Hi, 

 

I am new to power BI and i would like to combine two main tables into one. However, they are not of the same size. 

 

Table 1:

ProductCodePercentage
Prod1A30%
Prod1B30%
Prod1C40%
Prod2A25%
Prod2F25%
Prod2H50%
Prod3I15%
Prod3J25%
Prod3D25%
Prod3E35%
Prod4F14%
Prod4C21%
Prod4G30%
Prod4B35%

 

Table 2:

CategoryCodeQ1 2018Q2 2018Q3 2018Q4 2018
1A1.11.21.31.3
2B0.80.80.70.6
3C3.23.23.13
3D0.40.30.20.1
2E0.70.60.650.62
1F2.52.42.62.7
2G3.13.23.23.1
3H4.44.44.34.2
1I2.22.12.22.1

 

This is how the data is being stored. I would like to have the following output:

ProductQ1 2018Q2 2018Q3 2018Q4 2018
Prod1    
Prod2    
Prod3    
Prod4    

 

How do i create the table?

 

Thank you!

 

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

Hi.@Anonymous

 You can achieve the view by this

 

let
    Source = Web.Page(Web.Contents("https://community.powerbi.com/t5/Desktop/Multiply-two-or-more-tables/m-p/662123#M318163")),
    Data0 = Source{0}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Data0, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Product", type text}, {"Code", type text}, {"Percentage", Percentage.Type}})
in
    #"Changed Type"

Table 0

let
    Source = Web.Page(Web.Contents("https://community.powerbi.com/t5/Desktop/Multiply-two-or-more-tables/m-p/662123#M318163")),
    Data1 = Source{1}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Data1, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Category", Int64.Type}, {"Code", type text}, {"Q1 2018", type number}, {"Q2 2018", type number}, {"Q3 2018", type number}, {"Q4 2018", type number}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type",{"Code"},#"Table 0",{"Code"},"Table 0",JoinKind.LeftOuter),
    #"Expanded Table 0" = Table.ExpandTableColumn(#"Merged Queries", "Table 0", {"Product"}, {"Product"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded Table 0",{"Product", "Q1 2018", "Q2 2018", "Q3 2018", "Q4 2018"}),
    #"Grouped Rows" = Table.Group(#"Removed Other Columns", {"Product"}, {{"Q1 2018", each List.Sum([Q1 2018]), type number}, {"Q2 2018", each List.Sum([Q2 2018]), type number}, {"Q3 2018", each List.Sum([Q3 2018]), type number}, {"Q4 2018", each List.Sum([Q4 2018]), type number}})
in
    #"Grouped Rows"

Table 1

 

Capture.JPG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

2 REPLIES 2
smpa01
Super User
Super User

Hi.@Anonymous

 You can achieve the view by this

 

let
    Source = Web.Page(Web.Contents("https://community.powerbi.com/t5/Desktop/Multiply-two-or-more-tables/m-p/662123#M318163")),
    Data0 = Source{0}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Data0, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Product", type text}, {"Code", type text}, {"Percentage", Percentage.Type}})
in
    #"Changed Type"

Table 0

let
    Source = Web.Page(Web.Contents("https://community.powerbi.com/t5/Desktop/Multiply-two-or-more-tables/m-p/662123#M318163")),
    Data1 = Source{1}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Data1, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Category", Int64.Type}, {"Code", type text}, {"Q1 2018", type number}, {"Q2 2018", type number}, {"Q3 2018", type number}, {"Q4 2018", type number}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type",{"Code"},#"Table 0",{"Code"},"Table 0",JoinKind.LeftOuter),
    #"Expanded Table 0" = Table.ExpandTableColumn(#"Merged Queries", "Table 0", {"Product"}, {"Product"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded Table 0",{"Product", "Q1 2018", "Q2 2018", "Q3 2018", "Q4 2018"}),
    #"Grouped Rows" = Table.Group(#"Removed Other Columns", {"Product"}, {{"Q1 2018", each List.Sum([Q1 2018]), type number}, {"Q2 2018", each List.Sum([Q2 2018]), type number}, {"Q3 2018", each List.Sum([Q3 2018]), type number}, {"Q4 2018", each List.Sum([Q4 2018]), type number}})
in
    #"Grouped Rows"

Table 1

 

Capture.JPG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

Thank you! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.