Forum Discussion

elJukes's avatar
elJukes
Helper I
7 years ago
Solved

Help with table & matrix visual

Hello   I'm having a problem with table and matrix visuals. I've been wracking my brains and have looked online at resources but couldn't come up with a solution.   I have a data table of informa...
  • v-juanli-msft's avatar
    7 years ago

    Hi elJukes

    Which data source do you connect? do you connect live to the data source or import?

    Are you able to create measures or calculated columns or relationships between tables?

     

    If so, after transform table structure with power query, you could add the measure to the new table to indicate the assessment information from other table.

    could you show me example data so i can create a measure in the new created table.

     

    Based on my testing, some steps in your work are needed, such as "changed the values", "unpivoted the table", i don't know how did you apply these steps.

     

    Below is my test code in the Advanced editor.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXID4pCgUFcQ09En2FUpVidayQjI80VIgCmQuDFUA0Qlsg4TVKPgOkxRTUJoMMNplDlUC0wGYlYsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [StudentID = _t, Gender = _t, HasChar1 = _t, HasChar2 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"StudentID", Int64.Type}, {"Gender", type text}, {"HasChar1", type logical}, {"HasChar2", type logical}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"StudentID"}, "Attribute", "Value"),
        #"Duplicated Column" = Table.DuplicateColumn(#"Unpivoted Columns", "Attribute", "Attribute - Copy"),
        #"Split Column by Position" = Table.SplitColumn(#"Duplicated Column", "Attribute - Copy", Splitter.SplitTextByPositions({0, 5}, true), {"Attribute - Copy.1", "Attribute - Copy.2"}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Position",{{"Attribute - Copy.1", type text}, {"Attribute - Copy.2", type text}}),
        #"Added Conditional Column" = Table.AddColumn(#"Changed Type1", "Custom", each if [Value] = false then "Not" else null),
        #"Inserted Merged Column" = Table.AddColumn(#"Added Conditional Column", "Merged", each Text.Combine({[Custom], [#"Attribute - Copy.2"]}, " "), type text),
        #"Added Conditional Column1" = Table.AddColumn(#"Inserted Merged Column", "Custom.1", each if [Value] = "F" then "Female" else if [Value] = "M" then "Male" else if [Value] = true then [Attribute] else if [Value] = false then [Merged] else null),
        #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column1",{"Attribute", "Value", "Attribute - Copy.1", "Attribute - Copy.2", "Custom", "Merged"}),
        #"Grouped Rows" = Table.Group(#"Removed Columns", {"Custom.1"}, {{"Count", each Table.RowCount(_), type number}})
    in
        #"Grouped Rows"

     

    Best Regards

    Maggie