Forum Discussion

MylèneB's avatar
MylèneB
Icon for Helper II rankHelper II
7 years ago
Solved

Creating a matrix with multiple measures to display a distribution

Hi all,   I have trouble creating a matrix where I would like to put different measures I calculated to show a distribution.   I have this first table where I can see the names of the people and ...
  • TeigeGao's avatar
    7 years ago

    Hi MylèneB ,

    In your scenario, we need to unpivot the table using the following query in Edit Queries:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUbIwABLmIMLMQClWJ1opCcg0NUAiQILJQKYRiG8MIgwhgikw7UZIKlNhxlkaQKRBgmkQTVACqDw2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Score1 = _t, Score2 = _t, Score3 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Score1", Int64.Type}, {"Score2", Int64.Type}, {"Score3", Int64.Type}}),
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Name"}, "Attribute", "Value")
    in
        #"Unpivoted Other Columns"

    Then we will get a table like below:

    Then we can create a calculated column using the following DAX query:

    Column =
    IF (
        'Table'[Value] >= 60,
        ">=60",
        IF ( 'Table'[Value] >= 40 && 'Table'[Value] < 60, "40-60", "<40" )
    )

    After that, we can create a measure using the following DAX query:

    Measure 2 =
    DIVIDE (
        COUNTROWS ( 'Table' ),
        CALCULATE ( COUNTROWS ( 'Table' ), ALL ( 'Table'[Column] ) )
    )

    Then drag the fields and measure to matrix, we will get a table like below:

    Here is the pbix file, please refer to it: https://1drv.ms/u/s!AjytBuzIG5m9ti-8yXcTvKacfZLN

    Best Regards,

    Teige