Forum Discussion
sql
- 1 year ago
Hello JO8930
The first query simply sums the CategorySalesBudget values directly from the SubCategorySalesBudgetPSPD table with just a date filterThe second query joins the SubCategorySalesBudgetPSPD table with ProductDim and StoreDim tables before summing, which can cause multiplication of values
Check for duplicate keys in your dimension tables and ensure they have unique Subcategory and StoreID values. and Use DISTINCT in your JOIN keys
- Anonymous1 year ago
Hi JO8930 ,
Thanks for reaching out to the Microsoft Fabric Community. Also thank you nilendraFabric for correctly pointing out the cause.
The large difference you're seeing is due to the JOINs in the second query, which can duplicate rows if the dimension tables (ProductDim or StoreDim) contain multiple matching entries for the same Subcategory or StoreID. These duplicates inflate the SUM(CategorySalesBudget).
To resolve this, please verify that the dimension tables contain unique keys for the join fields. If not, you may need to review the data model or apply deduplication before joining.
If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.
Thankyou.
Hi JO8930 ,
Thanks for reaching out to the Microsoft Fabric Community. Also thank you nilendraFabric for correctly pointing out the cause.
The large difference you're seeing is due to the JOINs in the second query, which can duplicate rows if the dimension tables (ProductDim or StoreDim) contain multiple matching entries for the same Subcategory or StoreID. These duplicates inflate the SUM(CategorySalesBudget).
To resolve this, please verify that the dimension tables contain unique keys for the join fields. If not, you may need to review the data model or apply deduplication before joining.
If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.
Thankyou.