Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

How do i create a filter on feature?

Here is my underlying table   Product Feature_1 Feature_2 Feature_3 Feature_4 A 1 1 0 0 B 1 0 1 0 C 1 1 1 1 D 0 0 0 1 E 1 0 0 1   I would like to crea...
  • manvishah17's avatar
    2 years ago

    Hi Anonymous , 
    Yes you can do this in PowerBI .
    Go to Power Query and select all features column from 1 to 4 and unpivot it. 

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJBQrE60UoBRfkppcklQK5bamJJaVFqvCES2wiJbYzENgHrdQSKGEKxARiDRJ2QRAzhos5IaiEYJOoC1wlTDxJ1RTETLBoLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}}),
        #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
        #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"", type text}, {"_1", type text}, {"_2", type text}, {"_3", type text}, {"_4", type text}}),
        #"Promoted Headers1" = Table.PromoteHeaders(#"Changed Type1", [PromoteAllScalars=true]),
        #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers1",{{"Product", type text}, {"Feature_1", Int64.Type}, {"Feature_2", Int64.Type}, {"Feature_3", Int64.Type}, {"Feature_4", Int64.Type}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type2", {"Product"}, "Attribute", "Value"),
        #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Feature"}})
    in
        #"Renamed Columns"

     

    Then plot silcer of feature column and table of product column . 
    ADD Visual level filter in table where value = 1 

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!