let
Source = Excel.Workbook(File.Contents("C:\Users\lacik\OneDrive\Desktop\CURRENT\002 - Template Files\WISE-EUR-statement.xlsx"), null, true),
#"Balance Statement_Sheet" = Source{[Item="Balance Statement",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(#"Balance Statement_Sheet", [PromoteAllScalars=true]),
#"Added Conditional Column" = Table.AddColumn(#"Promoted Headers", "Type", each if [Amount] >= 0 then "Income" else "Expenses"),
#"Added Custom" = Table.AddColumn(#"Added Conditional Column", "Category", each null),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Acc.", each "WIS-EUR"),
#"Duplicated Column" = Table.DuplicateColumn(#"Added Custom1", "Amount", "AmountCopy"),
#"Split Column by Delimiter" = Table.SplitColumn(Table.TransformColumnTypes(#"Duplicated Column", {{"Amount", type text}}, "hu-HU"), "Amount", Splitter.SplitTextByDelimiter("-", QuoteStyle.None), {"AmountIn", "AmountOutTemp"}),
#"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter","",each [Currency],Replacer.ReplaceValue,{"Exchange To"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",null,each [AmountOutTemp],Replacer.ReplaceValue,{"Exchange To Amount"}),
#"Added Custom2" = Table.AddColumn(#"Replaced Value1", "Amount", each null),
#"Added Custom3" = Table.AddColumn(#"Added Custom2", "PerfDate", each null),
#"Added Custom4" = Table.AddColumn(#"Added Custom3", "Invoice", each null),
#"Added Custom5" = Table.AddColumn(#"Added Custom4", "⚠️", each null),
#"Added Custom6" = Table.AddColumn(#"Added Custom5", "AmountRaw", each null),
#"Added Custom7" = Table.AddColumn(#"Added Custom6", "Project ID", each null),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom7",{{"Date", type date}}, "en-GB"),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"AmountIn", type number}, {"Exchange To Amount", type number}, {"Exchange Rate", type number}}),
#"Merged Columns" = Table.CombineColumns(#"Changed Type1",{"ID", "Description", "Payment Reference"},Combiner.CombineTextByDelimiter(" | ", QuoteStyle.None),"Details"),
#"Reordered Columns1" = Table.ReorderColumns(#"Merged Columns",{"Date", "PerfDate", "Project ID", "Invoice", "⚠️", "Type", "Category", "Acc.", "AmountIn", "Exchange To Amount", "AmountOutTemp", "Exchange To", "Exchange Rate", "AmountRaw", "Amount", "Details", "AmountCopy", "Running Balance", "Exchange From", "Total Fees", "Payer Name", "Payee Name", "Payee Account Number", "Merchant", "Card Last Four Digits", "Card Holder Full Name", "Attachment", "Note", "Currency"}),
#"Removed Columns" = Table.RemoveColumns(#"Reordered Columns1",{"AmountOutTemp", "Total Fees", "Payer Name", "Payee Name", "Payee Account Number", "Merchant", "Card Last Four Digits", "Card Holder Full Name", "Attachment", "Note", "Currency", "Exchange From"}),
#"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"Exchange To", "Curr."}, {"Exchange Rate", "EXR"}}),
#"Reversed Rows" = Table.ReverseRows(#"Renamed Columns1"),
#"Added Index" = Table.AddIndexColumn(#"Reversed Rows", "Index", 1, 1, Int64.Type)
in
#"Added Index"