cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MacJasem
Frequent Visitor

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

ProductIDProductUnitSales

1

2 x

25 x
310 x

 

Table B

ProductIDProductSize
120 kg
230 kg
340 kg

 

Result i wish to see is:

Table A

ProductIDProductUnitSalesSalesVolume
33 x3 x 20 kg = 60 kg

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

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
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]?

 

If so, please try:

 

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.

 

If I have misunderstood your needs or if the problem remains unresolved, please feel free to contact us.

 

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

View solution in original post

1 REPLY 1
v-cgao-msft
Community Support
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]?

 

If so, please try:

 

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.

 

If I have misunderstood your needs or if the problem remains unresolved, please feel free to contact us.

 

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

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.