Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Custom MQuery Column -populate a (conditioned) value for as long as another column has repeated rows

Hi,   I'm trying to break out and classify my data so I can make several slicers to slice a particular data column. However, the data for my slicers is all contained in 2 columns: a key column whic...
  • ChrisMendoza's avatar
    6 years ago

    Anonymous -

     

    This seems like a possible solution.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLVMzCwUNJR8kvMTQVSXvkZeXmVQEZwSVFmXrohshAIxeog6XFMB2kxMUJRDhNBVeqempeSWgRk+CbmpKKrhwmDdVjqGRoYIRwUnJFYmgfXYIQkArcDpgPiHCNTFNUwEVSlcOe4peYiO8gI7iCoRGwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Some Result" = _t, Key = _t, Value = _t, Run = _t, Name = _t, Age = _t, Gender = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Some Result", type number}, {"Key", type text}, {"Value", type text}, {"Run", type text}, {"Name", type text}, {"Age", Int64.Type}, {"Gender", type text}}),
        #"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Name", "Gender"}),
        #"Filled Down" = Table.FillDown(#"Replaced Value",{"Name"}),
        #"Filled Up" = Table.FillUp(#"Filled Down",{"Gender"}),
        #"Grouped Rows" = Table.Group(#"Filled Up", {"Some Result"}, {{"Grouped", each _, type table [Some Result=number, Key=text, Value=text, Run=text, Name=text, Age=number, Gender=text]}}),
        #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.Sort([Grouped],{{"Age",Order.Descending}})),
        #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Some Result", "Key", "Value", "Run", "Name", "Age", "Gender"}, {"Some Result.1", "Key", "Value", "Run", "Name", "Age", "Gender"}),
        #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Grouped", "Some Result.1"}),
        #"Filled Down1" = Table.FillDown(#"Removed Columns",{"Age"})
    in
        #"Filled Down1"