Страницы: 1
RSS
PowerQuery. Копирование значения из вышерасположенной строки
 
Как на PowerQuery реализовать такое:
idproductcategoryproductcategoryproductcategory
1applefruitapplefruitapplefruit
2apricot apricotfruitapricotfruit
3peach step 1 =>peachfruitstep 2 =>peachfruit
4potato, tomatovegetablepotato, tomatovegetablepotatovegetable
5pumpkin pumpkinvegetabletomatovegetable
6cherryberrycherryberrypumpkinvegetable
cherryberry
или, если так будет понятнее, какой либо аналог запросу t-sql
step 1, variant 1

step 1, variant 2

step 1, variant 3
 
Ushla Shasvirnus,
Код
let
  data      = Excel.CurrentWorkbook(){[ Name = "data" ]}[Content],
  needClmns = Table.SelectColumns ( data, { "product", "category" } ),
  fillDown  = Table.FillDown ( needClmns, { "category" } ),
  split     = Table.TransformColumns ( fillDown, { { "product", ( x ) => Text.Split ( x, ", " ), type {text} } } ),
  expand    = Table.ExpandListColumn ( split, "product" )
in
  expand
 
Как вариант:
Код
let
    from = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    fill = Table.FillDown (from, {"category"}),
    split = Table.ExpandListColumn(Table.TransformColumns(fill,{"product", Splitter.SplitTextByDelimiter(", ", QuoteStyle.None)}), "product")[[product],[category]]
in
    split
 
Вариант кнопками
Код
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Filled Down" = Table.FillDown(Source,{"category"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Filled Down","product",Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv),{"product.1", "product.2"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Split Column by Delimiter", {"id", "category"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"id", "Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "product"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"product", "category"})
in
    #"Reordered Columns"
 
Не знаю, разрешено ли правилами форума благодарить. Тем не менее,
surkenny, memo, jakim,
спасибо.
Страницы: 1
Наверх