Forum Discussion
Transform a date to year-month
- 9 years ago
- 9 years ago
RvdHeijdenHere's DAX
Year-Wk = YEAR ( 'Calendar'[Date] ) & "-" & CONCATENATE ( IF ( WEEKNUM ( 'Calendar'[Date] ) < 10, "0", "" ), WEEKNUM ( 'Calendar'[Date] ) )Yes you may have to adjust WEEKNUM depending on when your week starts SUN (1) on MON (2)
I have skipped this optional parameter because the default is 1 which is what i need.
Hope this helps.
Good Luck!:smileyhappy:
- RvdHeijden9 years ago
Post Prodigy
Your 2 for 2, thanks a bunch, this works
- jleibowitz9 years agoRegular Visitor
Hi Sean,
I am trying to create a custom column to extract year/month from my date which is currently in the following format: 01/01/2017 but when I use the formula below, I recieve a 'Token Literal Expected' error for the 'Table' piece.
=FORMAT('Table'[Date], "YYYY-MM")
Also, if I try and use basic functions such as CONCATENATE, FORMAT, MONTH, YEAR, etc, I get an error that Power BI does not recognize the function. Thanks for the advice!
- Anonymous5 years agoNot applicable
How is this supposed to be used in the context of the query?
I tried adding this to a Table.AddColumn() clause as the last argument and it doesnt recognised FORMAT, What am I missing?