Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

how to switch values in matrix with multiple degree rows

Hi, here is my sample looks like:

version  south south1 south2 north north1 north2
A201920181110
B131917151712
C131520131617
D201810151419

and I need to visual it in matrix like this, the row level should remain indentation in matrix,

  ABCD
south 11141613
 south1 16181720
 south210201318
north  13141620
 north1 11181219
 north213111416

I created a dimension table:

dim_h1 dim_h2
south  south1
south south2
northnorth1
northnorth2

and write the measure:

Measure =
SWITCH(TRUE(),
SELECTEDVALUE('dimension'[dim_h1])="south",CALCULATE(SUM('table'[south])),
SELECTEDVALUE('dimension'[dim_h1])="north",CALCULATE(SUM('table'[north])),
SELECTEDVALUE('dimension'[dim_h2])="south1",CALCULATE(SUM('table'[south1])),
SELECTEDVALUE('dimension'[dim_h2])="south2",CALCULATE(SUM('table'[south2])),
SELECTEDVALUE('dimension'[dim_h2])="north1",CALCULATE(SUM('table'[north1])),
SELECTEDVALUE('dimension'[dim_h2])="north2",CALCULATE(SUM('table'[north2]))
)
but the result is like this, it seems level 2 dimension did not return the correct vlaue, and  I need to keep a identation in row level. can you help to correct the DAX?