Forum Discussion
petermb72
1 year agoHelper IV
Power Query Editor Nested if statements to put dates in a column
I am trying to put dates in a column based on the contents of another column. Here is an example of the data: Attribute Hours Date Column6 14 Column10 10 Column11 11 ...
- 1 year ago
Hi petermb72 ,
Sorry about that, i've made a mistake in my Code, but please, use the bellow M code:
if [Attribute] = "Column19" then Date.From(DateTime.LocalNow()) // Today's date else if [Attribute] = "Column17" then Date.AddDays(Date.From(DateTime.LocalNow()), -1) // Yesterday's date else if [Attribute] = "Column14" then Date.AddDays(Date.From(DateTime.LocalNow()), -2) // Day before yesterday else if [Attribute] = "Column13" then Date.AddDays(Date.From(DateTime.LocalNow()), -3) else if [Attribute] = "Column11" then Date.AddDays(Date.From(DateTime.LocalNow()), -4) else if [Attribute] = "Column10" then Date.AddDays(Date.From(DateTime.LocalNow()), -5) else if [Attribute] = "Column6" then Date.AddDays(Date.From(DateTime.LocalNow()), -6) else nullYour output will look like this:
VijayP
1 year agoCommunity Champion
It is most important to know why you wanted to do instead of what you wanted to do , it helps us to give right answer
petermb72
1 year agoHelper IV
I want to have the date for each of the items in the table going back for the week. I bring in the data everyday and it is a rolling 7 day period so the date would change for each line every day (forward one day).