Forum Discussion
Matrix column based on other matrix columns
- 10 months ago
hello markmsc
please check if this accomodate your need.
create a couple measures for apple, pear, elm, oak, and birch.
Apple =
SUMX(
FILTER(
'Table',
'Table'[Fruit]="Apple"
),
'Table'[Num1]
)Pear =
SUMX(
FILTER(
'Table',
'Table'[Fruit]="Pear"
),
'Table'[Num1]
)Elm =
var _Elm =
SUMX(
FILTER(
'Table',
'Table'[Tree]="Elm"
),
'Table'[Num2]
)
Return
DIVIDE(
_Elm,
[Apple]+[Pear]
)Oak =
var _Oak =
SUMX(
FILTER(
'Table',
'Table'[Tree]="Oak"
),
'Table'[Num2]
)
var _Melon =
SUMX(
FILTER(
'Table',
'Table'[Fruit]="Melon"
),
'Table'[Num1]
)
Return
DIVIDE(
_Oak,
_Melon
)Birch =
var _Birch =
SUMX(
FILTER(
'Table',
'Table'[Tree]="Birch"
),
'Table'[Num2]
)
Return
DIVIDE(
_Birch,
[Apple]+[Pear]
)Hope this will help.
Thank you. - 10 months ago
Hi,
Please check the below picture and the attached pbix file.
I tried to implement calculation group.
- 10 months ago
Another variant
1) I created the DimFruitTree table in Power Query
3) you need to sort the FruitTree column by Index
2) The relationship is like this - 10 months ago
For Fruit columns (Apple/Pear/Melon):
Fruit Measure = SUM(Data[Num1])
For Tree columns (Elm/Oak/Birch):
Tree Measure =
VAR AppleSum = CALCULATE([Fruit Measure], 'Data'[Fruit] = "Apple")
VAR PearSum = CALCULATE([Fruit Measure], 'Data'[Fruit] = "Pear")
VAR MelonSum = CALCULATE([Fruit Measure], 'Data'[Fruit] = "Melon")
RETURN
SWITCH(
SELECTEDVALUE('Data'[Tree]),
"Elm", DIVIDE(SUM(Data[Num2]), AppleSum + PearSum),
"Oak", DIVIDE(SUM(Data[Num2]), MelonSum),
"Birch", DIVIDE(SUM(Data[Num2]), AppleSum + PearSum)
)Use these measures in your matrix with City as rows, and Fruit/Tree as columns.
Hi,
Please check the below picture and the attached pbix file.
I tried to implement calculation group.
Hi Jihwan_Kim . Thank you very much for your detailed response. I wanted to reply to acknowledge your effort, and also to update that I need another day to evaluate this approach with my full dataset. I will follow up again soon.