Forum Discussion
replace measure item on matrix
- 8 years ago
Hi erihsehc,
In excel, when the result is gotten based on rows. In Power BI, the calculation is based on column, so you need to type the original sample table below.
sample table
Then, create a new table using the formula below.Table = SUMMARIZE(Table1,Table1[item],"Sum of amt",SUM(Table1[amt]))
Finally, get the right result by creating another new table based on the new table above.result = UNION ( 'Table' , ROW ( "item", "3.GP%", "Sum of amt", DIVIDE ( CALCULATE ( MAX ( 'Table'[sum of amt] ), FILTER ( 'Table', 'Table'[item] = "2.GP" ) ), CALCULATE ( MAX ( 'Table'[sum of amt] ), FILTER ( 'Table', 'Table'[item] = "1.sales" ) ) ) ), ROW ( "item", "6.PAT%", "Sum of amt", DIVIDE ( ( CALCULATE ( MAX ( 'Table'[Sum of amt] ), FILTER ( 'Table', 'Table'[item] = "1.sales" ) ) - CALCULATE ( MAX ( 'Table'[Sum of amt] ), FILTER ( 'Table', 'Table'[item] = "5.Cost" ) ) ), CALCULATE ( MAX ( 'Table'[Sum of amt] ), FILTER ( 'Table', 'Table'[item] = "1.sales" ) ) ) ) )expected result
Please download the attachment to check more details.
Best Regards,
Angelia
hi v-huizhn-msft, product A GP%=35/200=17.5%, product B GP%=23/100=23%, overall GP%=(23+35)/(100+200)=19.3%, same calculation for PAT%
the correct GP% should be 19.3% instead of 40.5%
Hi erihsehc,
In excel, when the result is gotten based on rows. In Power BI, the calculation is based on column, so you need to type the original sample table below.
sample table
Then, create a new table using the formula below.
Table = SUMMARIZE(Table1,Table1[item],"Sum of amt",SUM(Table1[amt]))
Finally, get the right result by creating another new table based on the new table above.
result =
UNION (
'Table' ,
ROW (
"item", "3.GP%",
"Sum of amt", DIVIDE (
CALCULATE (
MAX ( 'Table'[sum of amt] ),
FILTER ( 'Table', 'Table'[item] = "2.GP" )
),
CALCULATE (
MAX ( 'Table'[sum of amt] ),
FILTER ( 'Table', 'Table'[item] = "1.sales" )
)
)
),
ROW (
"item", "6.PAT%",
"Sum of amt", DIVIDE (
(
CALCULATE (
MAX ( 'Table'[Sum of amt] ),
FILTER ( 'Table', 'Table'[item] = "1.sales" )
)
- CALCULATE (
MAX ( 'Table'[Sum of amt] ),
FILTER ( 'Table', 'Table'[item] = "5.Cost" )
)
),
CALCULATE (
MAX ( 'Table'[Sum of amt] ),
FILTER ( 'Table', 'Table'[item] = "1.sales" )
)
)
)
)
expected result
Please download the attachment to check more details.
Best Regards,
Angelia
- erihsehc8 years agoHelper III
thanks v-huizhn-msft, it is a very good method. However, it disconnected the connection with "product".
Is that possible to enable the filter by product? to get the result by product and add product to the next level for drill down
Best regards,
ER
- v-huizhn-msft8 years agoMicrosoft Employee
Hi erihsehc,
This is your another issue, please mark the right reply as answer at first. Then create a new thread for new requirement. Thanks for understanding.
Thanks,
Angelia