let
Źródło = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Zmieniono typ" = Table.TransformColumnTypes(Źródło,{{"Klient", type text}, {"Invoice Date", type date}, {"Item Description", type text}, {"Product Line", type text}, {"Product Type Description", type text}, {"price", Currency.Type}, {"number of pcs", Int64.Type}, {"Bottem Gauge", type text}, {"Body Gauge", type text}, {"Top Gauge", type text}, {"Customer Item Number", type text}}),
#"Added Revenue" = Table.AddColumn(#"Zmieniono typ", "Total Revenue", each [price] * [number of pcs], Currency.Type),
GaugeText = (GaugeInput) =>
let
#"Replace 0" = Text.Replace(GaugeInput,"0",""),
#"Replace ." = Text.Replace(#"Replace 0",".",""),
#"Replace MM" = Text.Replace(#"Replace ."," MM",""),
#"Replace Second Choice" = Text.Replace(#"Replace MM","SECOND CHOICE",""),
#"Replace 12 with 2" = Text.Replace(#"Replace Second Choice","12","2")
in
#"Replace 12 with 2",
#"Added Barrel Description" = Table.AddColumn(#"Added Revenue", "Opis beczki", each if [Product Line] <> "Large Steel Drums>=44G/160ltr+" then null else Text.Combine({Text.Combine(List.ReplaceMatchingItems({Text.Start([Item Description],2)},{{"OL","OH"},{"RL","OH"},{"RH","OH"},{"TC","TH"}})),GaugeText([Top Gauge]) & GaugeText([Body Gauge]) & GaugeText([Bottem Gauge]),if Text.Middle([Item Description],22,1) = "L" then " IC" else null}," "), type text),
#"Reordered Columns" = Table.ReorderColumns(#"Added Barrel Description",{"Klient", "Invoice Date", "Item Description", "Product Line", "Product Type Description", "price", "number of pcs", "Total Revenue", "Bottem Gauge", "Body Gauge", "Top Gauge", "Opis beczki", "Customer Item Number"})
in
#"Reordered Columns"
Bookmarks