Forum Discussion
FZOU
Helper IV
6 years agoDax Soustract DATE
Hello, I need your help guys to achieve a formula. I have a column that containt "Year-Month" for exp : YearMonth 2019-01 2019-02 2019-03 N.. I have another column that contains number ...
- 6 years ago
Hi FZOU ,
Can you change the data type of column "YearMonth" from Text to Date? If yes, maybe you could try this:
Column = DATE ( YEAR ( 'Table'[YearMonth] ), MONTH ( 'Table'[YearMonth] ) - 'Table'[MonthN], DAY ( 'Table'[YearMonth] ) )And then format the new column as "yyyy-mm".
FZOU
Helper IV
6 years agoamitchandak it's impssible to format text as date !
amitchandak
Super User
6 years agoTry like
format(date(year(left([month-year]),4),month(mid([month-year],search("-",[month-year],1,0)+1,len([month-year])))-9,1),"YYYY-MM")
To get the correct value of the month please check this separately - mid([month-year],search("-",[month-year],1,0)+1,len([month-year]))