Forum Discussion
Hierarchy in the table matrix
Hello community, I haven't asked for help in a long time, but I faced such a problem
I have several measures that I want to group in a matrix visualization.
For the hierarchy, I created a simple table.
| ID | P1 | P2 |
| 1 | Stock balance | Stock balance |
| 2 | Receivables | R_Cashless |
| 2 | Receivables | R_Cash |
| 3 | Payables | P_Cashless |
| 3 | Payables | P_Cash |
I have measures corresponding to column names P1 and P2
My expected output should look like this. When the receivables are expanded, I should see the amount that goes to Cashless and Cash
| Stock balance | 150 |
| Receivables | 100 |
| R_Cashless | 70 |
| R_Cash | 30 |
| Payables | 300 |
| P_Cashless | 200 |
| P_Cash | 100 |
I tried to implement it through SWITCH, but for some reason I don't see the Debitor's hierarchy
Hi DimaMD ,
Based on your additional description, please try code as below.
MEASURE = VAR _P1 = SELECTEDVALUE ( Table1[P1] ) VAR _P2 = SELECTEDVALUE ( Table1[P2] ) RETURN IF ( ISINSCOPE ( 'Table1'[P2] ), SWITCH ( _P2, "R_Cashless", [R_Cashless], "R_Cash", [R_Cash], "P_Cashless", [P_Cashless], "P_Cash", [P_Cash], "Stock balance", [Stock balance] ), SWITCH ( _P1, "Stock balance", [Stock balance], "Receivables", [Receivables], "Payables", [Payables] ) )Result is as below.
Hope that works for you.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
12 Replies
- v-weiyan1-msft
Community Support
Hi DimaMD ,
Based on your additional description, please try code as below.
MEASURE = VAR _P1 = SELECTEDVALUE ( Table1[P1] ) VAR _P2 = SELECTEDVALUE ( Table1[P2] ) RETURN IF ( ISINSCOPE ( 'Table1'[P2] ), SWITCH ( _P2, "R_Cashless", [R_Cashless], "R_Cash", [R_Cash], "P_Cashless", [P_Cashless], "P_Cash", [P_Cash], "Stock balance", [Stock balance] ), SWITCH ( _P1, "Stock balance", [Stock balance], "Receivables", [Receivables], "Payables", [Payables] ) )Result is as below.
Hope that works for you.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- DimaMD
Solution Sage
Hi v-weiyan1-msft So this is what I was looking for, the measure worked correctly with my data, thank you very much
- lbendlin
Super User
In the matrix, Values settings, did you select "show values on rows" ?
- v-weiyan1-msft
Community Support
Hi DimaMD ,
Based on your description,
I suggest you can create a one-to-one relationship between the two tables.Then use the following code to create Measure.
Measure = VAR _P1 = SELECTEDVALUE(Table1[P1]) RETURN SWITCH( _P1, "Stock balance", [Stock balance], "Receivables", [R_Cash] + [R_Cashless], "Payables",[P_Cash] + [P_Cashless] )Result is as below.
In addition, I am not sure how your semantic model was created, but if the data for Table2 is as follows.
Then "Amount" field can be placed in the matrix without creating Measure. Result is as below.
You can refer to this, but still as your actual situation as a starting point.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- DimaMD
Solution Sage
Hi v-weiyan1-msft Thanks for the solution, but in my package there should not be a connection between the tables, in my original file the names of the measures are different