Forum Discussion
Create a date calculation
- 6 years ago
Here is the Power Query code, same logic as the DAX code and the DAX is prettier...
= Table.AddColumn(#"Changed Type", "Custom", each let Year = Date.Year(DateTime.Date([Date])), Month = Date.Month(DateTime.Date([Date])), Day = Date.Day(DateTime.Date([Date])) in if (Day >= 26) and (Month = 12) then #date(Year+1,1,26) else if (Day >= 26) then #date(Year,Month+1,26) else #date(Year,Month,26))
Thank you for this,
Is this added as a Custom Column? if so I am getting a "Token Eof expected" error
when I select show error, it highlights __Year
Martin
Yes and I don't get that, attached the PBIX. I did add some spaces between things. I have seen that internationally sometimes having numbers butted up against commas causes problems. If it isn't that, not sure. Seems to work for me.
- LUCASM6 years ago
Helper IV
Hi Greg_Deckler
Is this for Power BI or Power Query - (or both)
as you dropped in a pbix file
I need this to be added to PowerQuery (get and transform in Excel)
Maybe the two are synonymouos but as written it ios not recognised by PowerQuery in Excel as a Custom Column
- Greg_Deckler6 years ago
Community Champion
Here is the Power Query code, same logic as the DAX code and the DAX is prettier...
= Table.AddColumn(#"Changed Type", "Custom", each let Year = Date.Year(DateTime.Date([Date])), Month = Date.Month(DateTime.Date([Date])), Day = Date.Day(DateTime.Date([Date])) in if (Day >= 26) and (Month = 12) then #date(Year+1,1,26) else if (Day >= 26) then #date(Year,Month+1,26) else #date(Year,Month,26))- LUCASM6 years ago
Helper IV
Thats awesome. I now know why I didnt have a snowballs chance of resolving that on my own.
many many thanks
- Greg_Deckler6 years ago
Community Champion
Guess I should have checked the forum. This is for DAX, let me see if I an whip up a Power Query version.