I have a question on Power BI, basically i have a column with date (HIREDATE), and my task is to add a column that calculate the difference between the ACTUAL date and the date on my column. So it needs to be dynamic. I watched some youtube videos but haven't found a case like mine, even though i think it's a common, not very rare task. Following a tutorial on Youtube and on Microsoft WebSite I added a custom column named Experience with the following code :
= Duration.ToRecord ( YEAR(TODAY()) - [#"Date d'embauche"]) /* Date d'embauche = HIREDATE in french*/
It shows me :
Normally it is best to do these sort of transformations in Power Query before getting to the data model.
CodePudding user response:
Probably you are adding the Custom column in Power Query. I would rather recommend to add a Calculated Column through the following DAX expression:
Date difference = YEAR ( TODAY () ) - YEAR ( 'Table Name'[HIREDATE] )