Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I need help adjusting the measure below. I have a tenure calculated column for all employees based on Today's date or Term Date. I need to change the measure to calculate tenure based on the date selected in the Date Slicer not on Today's date. Example: If I selected January I would get the assocaites tenure as of January not Today's Month.
Solved! Go to Solution.
[Tenure] = // measure, not a calc column
// Make sure only one employee is visible
// in the current context. If there are many,
// it makes no sense to calculate tenure.
var ShoudCalculate = HASONEVALUE( 'Associate Data'[EmployeeID] )
var Result =
if ( ShouldCalculate,
// Grab the last date that's in context from the slicer
// and treat this date as today in your code.
// Slicer should not be connected to anything and you
// should make sure in the slicer UI that only one date
// can be selected.
VAR TermDate = MAX( 'Date Slicer'[Date] )
VAR LastHireDate = SELECTEDVALUE( 'Associate Data'[Last Hire Date] )
VAR TotalMonths = DATEDIFF ( LastHireDate, TermDate, MONTH )
VAR DayCondition = INT( DAY ( LastHireDate ) > DAY ( TermDate ) )
VAR YearsFractional = ( TotalMonths - DayCondition ) / 12
VAR Years = INT ( YearsFractional )
VAR TempMonths = ( YearsFractional - Years ) * 12
VAR Months = ROUND ( TempMonths, 0 )
RETURN
Years & " year(s) " & Months & " month(s)"
)
return
Result
Is this a measure and not a column? How can I turn it into a column?
If the formula I gave you is OK, please mark my answer as the solution so that the status is visible to others. Thanks.
Tenure measure is coming in blank
Is this a measure? I need a column in order to add slicers to tenure less than 1 year.
[Tenure] = // measure, not a calc column
// Make sure only one employee is visible
// in the current context. If there are many,
// it makes no sense to calculate tenure.
var ShoudCalculate = HASONEVALUE( 'Associate Data'[EmployeeID] )
var Result =
if ( ShouldCalculate,
// Grab the last date that's in context from the slicer
// and treat this date as today in your code.
// Slicer should not be connected to anything and you
// should make sure in the slicer UI that only one date
// can be selected.
VAR TermDate = MAX( 'Date Slicer'[Date] )
VAR LastHireDate = SELECTEDVALUE( 'Associate Data'[Last Hire Date] )
VAR TotalMonths = DATEDIFF ( LastHireDate, TermDate, MONTH )
VAR DayCondition = INT( DAY ( LastHireDate ) > DAY ( TermDate ) )
VAR YearsFractional = ( TotalMonths - DayCondition ) / 12
VAR Years = INT ( YearsFractional )
VAR TempMonths = ( YearsFractional - Years ) * 12
VAR Months = ROUND ( TempMonths, 0 )
RETURN
Years & " year(s) " & Months & " month(s)"
)
return
Result
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 33 | |
| 31 | |
| 19 | |
| 12 | |
| 11 |