Forum Discussion
Anonymous
7 years agoNot applicable
Percentage Contribution to all Levels using measures
Hi Team, Need help here to calcuate Percentage Contribution to all the levels . 1.Product to Total Contribution is working fine for me. ProductPerc = SUM (PRODUCTS[SALESAMOUNT]) / CALCULATE ...
- Anonymous7 years ago
I'll attach the pbix below, but here's the idea:
- Created dimenson tables for Category, Product and SubCategory and related those to your main table (not really needed in this case, but you would be better off storing keys in your main - aka fact - tables). You can see how I did that in Query Editior
- With Product Name from the new dimension product table:
- Prod to total is the easiest:
Total Sales = sum( Table1[SalesAmount] ) Grand Total Sales Product = CALCULATE( [Total Sales], all( DimProductName[ProductName])) Product to Total Contribution = DIVIDE( [Total Sales], [Grand Total Sales Product] )
- But now we get a little more tricky since category and subcategory arent in the table:
Grand Total of SubSales = CALCULATE( SUMX( ADDCOLUMNS( SUMMARIZE( Table1, DimProductName[ProductName], DimSubcategory[SubCategory]), "Total Sub Sales", CALCULATE( [Total Sales], FILTER( ALL( Table1), Table1[Subcategory] = EARLIER( DimSubcategory[SubCategory]) ) ) ), [Total Sub Sales] ) ) Product to SubCat Contribution = DIVIDE( [Total Sales], [Grand Total of SubSales])then the same logic for category:Grand Total of Category = CALCULATE( SUMX( ADDCOLUMNS( SUMMARIZE( Table1, DimProductName[ProductName], DimCategory[Category]), "Total Sub Sales", CALCULATE( [Total Sales], FILTER( ALL( Table1), Table1[Category] = EARLIER( DimCategory[Category]) ) ) ), [Total Sub Sales] )) Produc to Categoy Contr = DIVIDE( [Total Sales], [Grand Total of Category])Final matrix. Dont need or probably want the grand total on each row, but left them on there for demonstration purposes
here's the file:
Anonymous
7 years agoNot applicable
I'll attach the pbix below, but here's the idea:
- Created dimenson tables for Category, Product and SubCategory and related those to your main table (not really needed in this case, but you would be better off storing keys in your main - aka fact - tables). You can see how I did that in Query Editior
- With Product Name from the new dimension product table:
- Prod to total is the easiest:
Total Sales = sum( Table1[SalesAmount] ) Grand Total Sales Product = CALCULATE( [Total Sales], all( DimProductName[ProductName])) Product to Total Contribution = DIVIDE( [Total Sales], [Grand Total Sales Product] )
- But now we get a little more tricky since category and subcategory arent in the table:
Grand Total of SubSales = CALCULATE( SUMX( ADDCOLUMNS( SUMMARIZE( Table1, DimProductName[ProductName], DimSubcategory[SubCategory]), "Total Sub Sales", CALCULATE( [Total Sales], FILTER( ALL( Table1), Table1[Subcategory] = EARLIER( DimSubcategory[SubCategory]) ) ) ), [Total Sub Sales] ) ) Product to SubCat Contribution = DIVIDE( [Total Sales], [Grand Total of SubSales])then the same logic for category:Grand Total of Category = CALCULATE( SUMX( ADDCOLUMNS( SUMMARIZE( Table1, DimProductName[ProductName], DimCategory[Category]), "Total Sub Sales", CALCULATE( [Total Sales], FILTER( ALL( Table1), Table1[Category] = EARLIER( DimCategory[Category]) ) ) ), [Total Sub Sales] )) Produc to Categoy Contr = DIVIDE( [Total Sales], [Grand Total of Category])Final matrix. Dont need or probably want the grand total on each row, but left them on there for demonstration purposes
here's the file:
HKSpring
3 years agoRegular Visitor
Hi,
May I request the pbix file again? The above attached link is expired or not working anymore.
Tks in advance