Forum Discussion
Khomotjo
Helper II
1 year agoConvert Month Name to Month No
Hello Everyone, I have a coloumn that has month names and want to convert these to integers so that I can use Date function( I have coloumns that have the day and the year ). I tried : switch ...
- 1 year ago
Hi Khomotjo ,
Please use the bellow DAX to achieve your goal:
MonthNumber = SWITCH( TRUE(), 'Table'[month_name] = "January", 1, 'Table'[month_name] = "February", 2, 'Table'[month_name] = "March", 3, 'Table'[month_name] = "April", 4, 'Table'[month_name] = "May", 5, 'Table'[month_name] = "June", 6, 'Table'[month_name] = "July", 7, 'Table'[month_name] = "August", 8, 'Table'[month_name] = "September", 9, 'Table'[month_name] = "October", 10, 'Table'[month_name] = "November", 11, 'Table'[month_name] = "December", 12, BLANK() -- Default case if no match is found )Make sure to replace 'Table'[month_name] with name of your table and column that contain months as String
Bibiano_Geraldo
Super User
1 year agoHi Khomotjo ,
Please use the bellow DAX to achieve your goal:
MonthNumber =
SWITCH(
TRUE(),
'Table'[month_name] = "January", 1,
'Table'[month_name] = "February", 2,
'Table'[month_name] = "March", 3,
'Table'[month_name] = "April", 4,
'Table'[month_name] = "May", 5,
'Table'[month_name] = "June", 6,
'Table'[month_name] = "July", 7,
'Table'[month_name] = "August", 8,
'Table'[month_name] = "September", 9,
'Table'[month_name] = "October", 10,
'Table'[month_name] = "November", 11,
'Table'[month_name] = "December", 12,
BLANK() -- Default case if no match is found
)
Make sure to replace 'Table'[month_name] with name of your table and column that contain months as String