I am trying to recreate this Excel formula in Power Query. I have very little idea what I am doing so I need some help.
=\[@\[DOC ID\]\] &"-"&COUNTIF(\[DOC ID\],\[@\[DOC ID\]\])
I am modifying someone else's Power Query, so any help would be great.
let
Source = ReqProcBudget2024,
#"Filtered Rows" = Table.SelectRows(Source, each ([Doc Type] = "PO: ")),
#"Replaced Value" = Table.ReplaceValue(#"Filtered Rows",null,"",Replacer.ReplaceValue,{"Line\Sched\Dist", "Vendor"}),
#"Merged Queries" = Table.NestedJoin(#"Replaced Value", {"Budg Dt"}, FY_Dates, {"Date"}, "FY_Dates", JoinKind.LeftOuter),
#"Expanded FY_Dates" = Table.ExpandTableColumn(#"Merged Queries", "FY_Dates", {"Index"}, {"Index"}),
#"Removed Duplicates" = Table.Distinct(#"Expanded FY_Dates", {"DOC ID", "Line\Sched\Dist", "Vendor", "Original Amount", "Account", "Department", "Fund"}),
#"Added Custom" = Table.AddColumn(#"Removed Duplicates", "Show COVID Related POs?", each if Text.Contains([PO Ref], "COVID",Comparer.OrdinalIgnoreCase) then "YES" else "NO"),
#"Added Conditional Column" = Table.AddColumn(#"Added Custom", "PO Original Amount by Line Item", each if [Original Amount] >= 50000 then "$50k or MORE" else "LESS than $50k"),
#"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "PO Remaining Amount by Line Item", each if [Remaining Amount] >= 50000 then "$50k or MORE" else "LESS than $50k"),
#"Changed Type" = Table.TransformColumnTypes(#"Added Conditional Column1",{{"Show COVID Related POs?", type text}, {"PO Original Amount by Line Item", type text}, {"PO Remaining Amount by Line Item", type text}})
in
#"Changed Type"
This is what I have from the Power Query from them. I am just trying to get it to do what I can do in Excel.
I have tried adding:
= Table.AddColumn(#"Changed Type", "UI", each [DOC ID] & "-" & Text.From(Table.RowCount(Table.SelectRows(#"Changed Type", each [DOC ID] = _[DOC ID]))))
It gives me "DOC ID"- 9481 on every line.
It should be "DOC ID"-1 or "DOC ID"- 2 depending on if it is the first instance of the "DOC ID".
Please help.
