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.
Hi, all.
I'm working on a measure that I can't quite figure out, and I think it may be a relationship issue with my date table.
The goal: Produce a line chart with the average employee tenure on any specific date over the life of my data set.
What I have (2 Measures):
Solved! Go to Solution.
Hi @Dave1mo1
Would something like this help?
Avg Tenure =
VAR _Curr = SELECTEDVALUE( 'Date'[Date] )
VAR _Table =
ADDCOLUMNS(
FILTER(
SUMMARIZE(
ALL( 'Employee' ),
'Employee'[ID],
'Employee'[Date of Hire],
'Employee'[Actual Termination Date]
),
[Date of Hire] <= _Curr
&& COALESCE( [Actual Termination Date], _Curr ) >= _Curr
),
"__Days",
DATEDIFF( [Date of Hire], _Curr, DAY ) + 1
)
VAR _Avg =
AVERAGEX(
_Table,
[__Days]
)
RETURN
_Avg
Let me know if you have any questions.
Average Employee Tenure Over Time - Line-Chart.pbix
Hi @Dave1mo1
Would something like this help?
Avg Tenure =
VAR _Curr = SELECTEDVALUE( 'Date'[Date] )
VAR _Table =
ADDCOLUMNS(
FILTER(
SUMMARIZE(
ALL( 'Employee' ),
'Employee'[ID],
'Employee'[Date of Hire],
'Employee'[Actual Termination Date]
),
[Date of Hire] <= _Curr
&& COALESCE( [Actual Termination Date], _Curr ) >= _Curr
),
"__Days",
DATEDIFF( [Date of Hire], _Curr, DAY ) + 1
)
VAR _Avg =
AVERAGEX(
_Table,
[__Days]
)
RETURN
_Avg
Let me know if you have any questions.
Average Employee Tenure Over Time - Line-Chart.pbix
Sorry it took so long to get back to you - this is perfect, thank you!
Is there any way to tweak the measure so that it responds to filters on my filter panel, however? It's also possible I'm doing something wrong and it's not an issue with the measure, of course.
Hi @Dave1mo1
I think I know which changes to make but to be sure, I'll need a pbix with dummy data. (See my first post.)
Hopefully it won't take many changes.
I've tried a couple times to include the link but failed. Can you see if this link works?
Hi @Dave1mo1
Can you provide the following?
1) Please provide sample data that covers your issue or question completely.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
2) Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
A .pbix file with sample data would be best.