The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I would like to create a text box in PowerBI that says "I have been working at company for x years (or months)". I would like the number of years they have been with the company to update automatically.
My data currently include a column for Employee Name and a column with Start Date.
How can I calculate for this value to be displayed?
Solved! Go to Solution.
Hi,
you can follow these steps:
1. Create a New Column for Years of Service
YearsOfService = DATEDIFF([Start Date], TODAY(), YEAR)
2. Create a New Column for Months of Service (if needed):
MonthsOfService = DATEDIFF([Start Date], TODAY(), MONTH)
3. Create a Measure for the Text Box
ServiceText = "I have been working at the company for " & [YearsOfService] & " years."
Proud to be a Super User! | |
If you would like to do it with a measure it would look something like this.
Tenure =
VAR _Start = SELECTEDVALUE('YourTable'[Start Date])
VAR _YS = YEAR(_Start)
VAR _MS = MONTH(_Start)
VAR _DS = DAY(_Start)
VAR _Today = TODAY()
VAR _YT = YEAR(_Today)
VAR _MT = MONTH(_Today)
VAR _DT = DAY(_Today)
VAR _YA = IF ( OR ( AND ( _MS = _MT, _DS > _DT ), _MS > _MT ), -1, 0)
VAR _Years = DATEDIFF(_Start,_Today,YEAR) + _YA
VAR _Months = DATEDIFF(_Start,_Today,MONTH)
RETURN "I have been working at the company for " & IF ( _Years > 0, _Years & IF ( _Years = 1, " year.", " years." ), _Months & IF ( _Months = 1, " month.", " months.") )
If you would like to do it with a measure it would look something like this.
Tenure =
VAR _Start = SELECTEDVALUE('YourTable'[Start Date])
VAR _YS = YEAR(_Start)
VAR _MS = MONTH(_Start)
VAR _DS = DAY(_Start)
VAR _Today = TODAY()
VAR _YT = YEAR(_Today)
VAR _MT = MONTH(_Today)
VAR _DT = DAY(_Today)
VAR _YA = IF ( OR ( AND ( _MS = _MT, _DS > _DT ), _MS > _MT ), -1, 0)
VAR _Years = DATEDIFF(_Start,_Today,YEAR) + _YA
VAR _Months = DATEDIFF(_Start,_Today,MONTH)
RETURN "I have been working at the company for " & IF ( _Years > 0, _Years & IF ( _Years = 1, " year.", " years." ), _Months & IF ( _Months = 1, " month.", " months.") )
Hi,
you can follow these steps:
1. Create a New Column for Years of Service
YearsOfService = DATEDIFF([Start Date], TODAY(), YEAR)
2. Create a New Column for Months of Service (if needed):
MonthsOfService = DATEDIFF([Start Date], TODAY(), MONTH)
3. Create a Measure for the Text Box
ServiceText = "I have been working at the company for " & [YearsOfService] & " years."
Proud to be a Super User! | |
User | Count |
---|---|
85 | |
84 | |
36 | |
34 | |
32 |
User | Count |
---|---|
93 | |
79 | |
66 | |
55 | |
52 |