Having some issues in blending the two tables to get a proper pivot chat table in looker studio.

i have 2 tables.
1 is tblForecast and another is tblSales.
tblForecast details is as follows:

dateitemCodefctSegmentfctQtyfctRevenue
2025/01/0120008Restaurant510015339604
2025/01/0120008Retail3301175764
2025/01/0120008Web414000
2025/01/0120008Wholesale808625126718
2025/02/0120008Restaurant510015339604
2025/02/0120008Retail3301175764
2025/02/0120008Web414000
2025/02/0120008Wholesale808625126718

for each item everymonth forecast qty and forecast revenue is set for four segments (Retail,web,wholesale and restuarant)
here are the few records

Now i have another table as sales data. this is transactional table:

DateitemCodeqtySoldrevenuesalesTeamcustomerSegmentcostCenterActualSegment
2025/01/012000813150Kinki2.WholesaleM1Wholesale
2025/01/042000813675 4.RetailShop_SOKRetail
2025/01/042000813675SHOP KRM4.RetailShop_KRMRetail
2025/01/0420008514750SHOP KRM1.RestaurantShop_KRMRetail
2025/01/0420008311025 4.RetailShop_SMLRetail
2025/01/042000827350 4.RetailShop_NSKRetail
2025/01/052000813675 4.RetailShop_SMLRetail
2025/01/052000813675 4.RetailShop_NSKRetail
2025/01/052000825900SHOP KRM1.RestaurantShop_KRMRetail
2025/01/052000827350SHOP KRM4.RetailShop_SMLRetail
2025/01/0520008412600SHOP SOK2.WholesaleShop_SOKRetail
2025/01/052000827350 4.RetailShop_SOKRetail
2025/01/062000813675 4.RetailShop_SMLRetail
2025/01/062000813675 4.RetailShop_NSKRetail
2025/01/062000812950Hokkaido1.RestaurantM1Restaurant
2025/01/062000812950Kanto1.RestaurantM1Restaurant
2025/01/06200082066000KBS2.WholesaleM2Wholesale
2025/01/0620008823600SHOP SOK1.RestaurantShop_SOKRetail
2025/01/06200082277000 4.RetailAmbika_WebWeb
2025/01/062000827350 4.RetailShop_SOKRetail
2025/01/062000825900 5.Staff (Restaurant)M1Retail
2025/01/06200082888200Wholesale 12.WholesaleM1Wholesale
2025/01/062000832100800Wholesale 22.WholesaleM1Wholesale
2025/01/0620008514750Group1.RestaurantM1Restaurant
2025/01/0620008720650Kanagawa1.RestaurantM1Restaurant
2025/01/0620008823600Kobe1.RestaurantM1Restaurant
2025/01/0620008720650Chubu1.RestaurantM1Restaurant
2025/01/062000848143148Japanese1.RestaurantM1Restaurant
2025/01/06200082877600Tokyo1.RestaurantM1Restaurant
2025/01/072000813675 4.RetailShop_KRMRetail
2025/01/072000812950SHOP KRM1.RestaurantShop_KRMRetail
2025/01/0720008413200KBS2.WholesaleM2Wholesale
2025/01/0720008411800SHOP SOK1.RestaurantShop_SOKRetail
2025/01/072000846144900SHOP SOK2.WholesaleShop_SOKRetail
2025/01/07200082277000 4.RetailAmbika_WebWeb
2025/01/0720008514750Tokyo3.OtherM1Retail
2025/01/072000848143200Group2.WholesaleM1Wholesale
2025/01/07200081444100Chubu2.WholesaleM1Wholesale

now i want to create a blend where i can get a chart table (piovt) in the following way
when i select the date control from 1st Jan to 07st jan
itemCode, fctQty, qtySold, sold%,fctRevenue, Revenue
20008, 13520, 391, 2.89%, 41656086, 1222248..
when i change the date to Feb, it changes accordingly..
I hope you unestrand the problem i getting because fctTble has single date (for each mont) but salesTable is a transactional table so it has same date and many other date in the same month multiple times.  Pleas help! i have tried using chatgpt..but fail!. 


0 1 54
1 REPLY 1

This is a tough one in Looker Studio. When you blend together two tables on a join condition that has multiple shared values, the data will fanout as you're seeing here. 

(In Looker, there are many ways to deal with fanout. You can define a join as many_to_many, for example! And you can create fields like sum_distinct that let you automatically remove fanout on a field. But Looker Studio doesn't have these options, so we'll have to get hacky.)

There is a workaround, though it's not very clean. You can compute the fanout number and then divide your metrics by that.

For example,  you said that you wanted the qtySold to be 391. When I blended these two tables together, I got 1564 for qtySold. Notice that 1564/391 = 8. Why is this a round number, and where is the 8 coming from? Well, the qtySold is being repeated once for each of the 4 fctSegment values and once for each of the 2 dates in the tblForecast table.

So, we can "de-duplicate" the value by creating a new metric that divides out the duplicate values we create through the blend. The formula for a corrected qtySold total would look like this:

 

SUM(qtySold) / ( 
  COUNT_DISTINCT(fctSegment)
  * COUNT_DISTINCT(date_tblForecast)
)

You would have to do this for each metric that is overinflated. That's the best I've got, but it still feels pretty hacky. Does anyone else have ideas on avoiding fanout when blending in Looker Studio?