Forum Discussion
Power Query for Multiple category
- 5 years ago
Hi, dilipan_mp
Based on your description, I'd like to suggest you try creating measures and displaying the result in a matrix visual. I created data to reproduce your scenario.
Table:
You may create three measures as below.
Total Production = var txt = LEFT(SELECTEDVALUE('Table'[KPI]),2) return IF( ISINSCOPE('Table'[KPI]), IF( txt<>"PC", SUM('Table'[KPI Value]) ), IF( ISINSCOPE('Table'[City]), CALCULATE( SUM('Table'[KPI Value]), FILTER( 'Table', 'Table'[KPI Category]="Production" ) ), CALCULATE( SUM('Table'[KPI Value]), FILTER( 'Table', 'Table'[KPI Category]="Production" ) ) ) )% of Total Production = var txt = LEFT(SELECTEDVALUE('Table'[KPI]),2) return IF( ISINSCOPE('Table'[KPI]), IF( txt<>"PC", DIVIDE( SUM('Table'[KPI Value]), CALCULATE( SUM('Table'[KPI Value]), FILTER( ALLEXCEPT('Table','Table'[City]), 'Table'[KPI Category]="Production" ) ) ) ), IF( ISINSCOPE('Table'[City]), 1, DISTINCTCOUNT('Table'[City]) ) )Total Production/Total Power = var txt = LEFT(SELECTEDVALUE('Table'[KPI]),2) return IF( ISINSCOPE('Table'[KPI]), IF( txt<>"PC", [% of Total Production]* CALCULATE( SUM('Table'[KPI Value]), FILTER( ALLEXCEPT('Table','Table'[City]), 'Table'[KPI Category]="Power" ) ) ), IF( ISINSCOPE('Table'[City]), CALCULATE( SUM('Table'[KPI Value]), FILTER( ALLEXCEPT('Table','Table'[City]), 'Table'[KPI Category]="Power" ) ), CALCULATE( SUM('Table'[KPI Value]), FILTER( 'Table', 'Table'[KPI Category]="Power" ) ) ) )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
dilipan_mp
What is the common key or a column that defines the link between Production and Power, for example, Product 1 and PC1, you cannot hard code, you need to have some relationship then you can merge and group and do the calculation easy to get the results.
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply š