Forum Discussion
Npg3
3 years agoNew Member
Power BI time functions
Hi, I want to create a function in power bi to creates a new colum and adds a certain amount of time depending on a key word that is a period of time in a different column. example: row 1...
- Anonymous3 years ago
Hi Npg3 ,
You can try M Code as below.
Date.AddMonths( [Column A], if [Column B] = "AOT" then 6 else if [Column B] = "XYZ" then 3 else if [Column B] = "ABC" then 1 else null)Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
tamerj1
Community Champion
3 years agoHi Npg3
It depends. If not too many text variants and if only number of months to be added then you may try
Column C =
EDATE (
'Table'[Column A],
SWITCH ( 'Table'[Column B], "AOT", 6, "XYZ", 3, "ABC", 1 )
)
- Npg33 years agoNew Member
It shows expression.error: the name 'EDATE' wasn't recognized. Make sure it's spelled right