Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Need to add columns to table visual based on slicer selection

I have a use-case wherein I am pulling a huge fact table from Azure Data Explorer and I need to create a table visual where there are few fixed columns in the visual and I need to provide a slicer wi...
  • v-yingjl's avatar
    5 years ago

    Hi Anonymous ,

    If cannot using unpivot feature due to the size of your data source, you can extract the column name as a new table like this(supposing there has been a column that you must show it in the visual, otherwise it could not be supported currently unless usng unpivot)

    In my sample, supposing the index column must be shown in the visual, the query could be like this:

    let
        Source = Table.ColumnNames(#"Table"),
        #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Column Name"}}),
        #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Column Name", type text}}),
        #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Column Name] <> "Index"))
    in
        #"Filtered Rows"

    Create a measure like this:

    A = 
    SWITCH (
        SELECTEDVALUE ( 'Column Name'[Column Name] ),
        "Column1", MAX ( 'Table'[Column1] ),
        "Column2", MAX ( 'Table'[Column2] ),
        "Column3", MAX ( 'Table'[Column3] ),
        "Column4", MAX ( 'Table'[Column4] ),
        "Column5", MAX ( 'Table'[Column5] ),
        "Column6", SUM ( 'Table'[Column6] ),
        "Column7", SUM ( 'Table'[Column7] ),
        "Column8", SUM ( 'Table'[Column8] ),
        "Column9", SUM ( 'Table'[Column9] ),
        "Column10", SUM ( 'Table'[Column10] )
    )

    Use a Matrix visual not a table visual to show the result:

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.