Forum Discussion
Help with identifying increase within a date range group
- 4 years ago
Jakinta - replied to you
Good morning Jakinta!
Thank you for this solution!... BTW... you are correct... I missed one PROMO scenario... you got it right.
I am having trouble putting the code into power query. I am putting it into power query in excel.. does that make a difference?
This is what my code looks like:
let
Source = Excel.CurrentWorkbook(){[Name="All_HR_Promos"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Personnel no.", Int64.Type}, {"Personnel Name", type text}, {"Salary Band", Int64.Type}, {"Reason on Pay Record", type text}, {"Year", Int64.Type}, {"Basic Pay Record Start Date", type datetime}, {"Basic Pay Record End Date", type datetime}, {"Current Position Title", type text}, {"Current Position #", Int64.Type}, {"Current Manager Name", type text}, {"Current Managing Position", type text}, {"Current Org Level 4", type text}, {"Current Org Level 5", type text}, {"Current Org Level 6", type text}, {"Current Org Level 7", type text}, {"Current Org Level 8", type text}}),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Changed Type", {"Salary Band"})
[#"Personnel no." = _t, #"Personnel Name" = _t, #"Salary Band" = _t, #"Reason on Pay Record" = _t, #"Basic Pay Record Start Date" = _t]),
Grouped = Table.Group(Source, {"Personnel no."}, {{"Gr", each let t=_ in Table.AddColumn( Table.AddColumn( Table.AddIndexColumn(t, "i",-1,1), "PROMO STATUS", each try if Number.From([#"Salary Band"]) > Number.From(t[#"Salary Band"]{[i]}) then "Promotion" else "" otherwise ""), "PROMO CYCLE", each if [#"PROMO STATUS"]="" then "" else if Date.Month(Date.From([#"Basic Pay Record Start Date"])) =3 then "On Cycle" else "Off Cycle" ), type table }}),
Removed = Table.RemoveColumns(Grouped,{"Personnel no."}),
FINAL = Table.ExpandTableColumn(Removed, "Gr",
List.RemoveItems (Table.ColumnNames(Removed[Gr]{0}), {"i"}))
in
FINAL
I am getting an error - Expression.SyntaxError: Token RightBracket expected.
It is showing that there is an error here:
[#"Personnel no." = _t, #"Personnel Name" = _t,
^
Please advise. Thank you!