cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Helper II

calculate the Size value from from Dimension table for the corresponding products in FactSales table

Hi Guys

Hope somebody can help me with this task.

I have two Tables, table A (FactTable) & table B (dimensionTable). Both of the has the ProductID Column, but i'm trying to get the corresponding Product Size values from table B into a new column in table A that matches the ProductID. I've tried to merge etc. and it didn't work.

The result i'm looking for is that in table A, for every product sale there's a column that shows the product size of that product.

Table A

 ProductID ProductUnitSales 1 2 x 2 5 x 3 10 x

Table B

 ProductID ProductSize 1 20 kg 2 30 kg 3 40 kg

Result i wish to see is:

Table A

 ProductID ProductUnitSales SalesVolume 3 3 x 3 x 20 kg = 60 kg

How and what is the best way to tackle this task?

1 ACCEPTED SOLUTION
Community Support

Hi @MacJasem ,

Are the data types of [ProductUnitSales], [ProductSize], [SalesVolume] numbers or text? If I understand correctly, do you want to get the summary value from table B corresponding to [ProductSize] and create a new column in table A by multiplying this value with [ProductUnitSales]?

``````let
Source = Table.NestedJoin(#"Table A", {"ProductID"}, #"Table B", {"ProductID"}, "Table B", JoinKind.LeftOuter),
#"Expanded Table B" = Table.ExpandTableColumn(Source, "Table B", {"ProductSize"}, {"Table B.ProductSize"}),
#"Added Custom" = Table.AddColumn(#"Expanded Table B", "SalesVolume", each [ProductUnitSales] * [Table B.ProductSize]),
#"Grouped Rows" = Table.Group(#"Added Custom", {"ProductID", "ProductUnitSales"}, {{"SalesVolume", each List.Sum([SalesVolume]), type number}})
in
#"Grouped Rows"``````

The PBIX file is attached for reference.

Best Regards,
Gao

Community Support Team

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Community Support

Hi @MacJasem ,

Are the data types of [ProductUnitSales], [ProductSize], [SalesVolume] numbers or text? If I understand correctly, do you want to get the summary value from table B corresponding to [ProductSize] and create a new column in table A by multiplying this value with [ProductUnitSales]?

``````let
Source = Table.NestedJoin(#"Table A", {"ProductID"}, #"Table B", {"ProductID"}, "Table B", JoinKind.LeftOuter),
#"Expanded Table B" = Table.ExpandTableColumn(Source, "Table B", {"ProductSize"}, {"Table B.ProductSize"}),
#"Added Custom" = Table.AddColumn(#"Expanded Table B", "SalesVolume", each [ProductUnitSales] * [Table B.ProductSize]),
#"Grouped Rows" = Table.Group(#"Added Custom", {"ProductID", "ProductUnitSales"}, {{"SalesVolume", each List.Sum([SalesVolume]), type number}})
in
#"Grouped Rows"``````

The PBIX file is attached for reference.

Best Regards,
Gao

Community Support Team

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Announcements

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Power BI Monthly Update - February 2024

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

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors