@Greg Apologies,
Bday.pbix (18.9 KB) Birthday.xlsx (127.4 KB)
Please find the corrected files.
As I mentioned I run into an issue while calculating the next coming bday for the person. The error occurs when someone is born 29/02.
I used below code to calcualte next bday.
let
Source = Excel.Workbook(File.Contents(“C:\Users\MWojnach\Documents\Project\Birthday.xlsx”), null, true),
Table1_Table = Source{[Item=“Table1”,Kind=“Table”]}[Data],
#“Changed Type” = Table.TransformColumnTypes(Table1_Table,{{“Dob”, type date}}),
#“Added Custom Column” = Table.AddColumn(#“Changed Type”, “Custom”, each Text.Combine({Date.ToText([Dob], “dd”), “-”, Date.ToText([Dob], “MMM”)}), type text),
#“Changed Type1” = Table.TransformColumnTypes(#“Added Custom Column”,{{“Custom”, type date}}),
#“Added Custom” = Table.AddColumn(#“Changed Type1”, “Today”, each DateTime.Date(DateTime.LocalNow())),
#“Added Custom1” = Table.AddColumn(#“Added Custom”, “Diff”, each [Custom]-[Today]),
#“Changed Type2” = Table.TransformColumnTypes(#“Added Custom1”,{{“Diff”, Int64.Type}, {“Today”, type date}}),
#“Added Custom2” = Table.AddColumn(#“Changed Type2”, “NextBday”, each if [Diff] < 0 then Date.AddYears([Custom],1) else [Custom]),
#“Added Custom3” = Table.AddColumn(#“Added Custom2”, “NextB-day days”, each [NextBday]-[Today]),
#“Changed Type3” = Table.TransformColumnTypes(#“Added Custom3”,{{“NextB-day days”, Int64.Type}})
in
#“Changed Type3”
The errors occur in applied steps (step Changed Type1) I understand why it happened as 29/02/2021 doesn’t exist.
I will appreciate it if you could guide me/ give me a hint on how could I resolve this error.
I thought to add additional logic such as if the year is ending 1 then add 3, if 2 then add 2 but then we would run into an issue if the year is ending 0 then you would add 4 or would add 0.
2020, 2024, 2028, 2032,2036,2040
Thank you,
Mateusz