Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi, I want to calculate Average tenure using 'Hiring Date' and 'Leaving date'.but in 'Leaving date' column there are some empty rows, i want replace empty rows with current date. so please help me in creating a dax code.
Solved! Go to Solution.
You're welcome 🙂
I think the above measure is doing what you want but let me check it with you. Let me know.
I have attached a sample PBIX.
Just to explain the measure:
Here are some sample outputs using a subset of your posted data plus some additional rows added by me:
In case you were considering adding a column that replaces blank Leaving Dates with TODAY(), you would just need to be aware that this column would generally only be updated when refresh occurs.
It's working, Thank you so much.
Hi @Vinay06
If you want to leave the blank Leaving Dates as they are, and in those cases treat "today" as the Leaving Date (when the measure is evaluated), you can write a measure like this:
Average Tenure (Days) =
VAR TodayDate = TODAY ()
RETURN
AVERAGEX (
YourTable,
COALESCE ( YourTable[Leaving Date], TodayDate ) -- Blanks changed to TODAY()
- YourTable[Hiring Date]
)
The above measure calcualtes tenure in days by subtracting dates. You can instead use DATEDIFF if you need something different.
Regards,
Owen
Thanks for spending your time for me. Actually i want to include those blank leaving dates but instead of blank value i want to replace them with today date,and can you provide dax code for calculating averege tenure as well.
1) calculate average tenure using Hiring date and Leaving date
2) Replace blank values in Leaving date with today date.
please provide me with a complete dax code for above mentioned points.
You're welcome 🙂
I think the above measure is doing what you want but let me check it with you. Let me know.
I have attached a sample PBIX.
Just to explain the measure:
Here are some sample outputs using a subset of your posted data plus some additional rows added by me:
In case you were considering adding a column that replaces blank Leaving Dates with TODAY(), you would just need to be aware that this column would generally only be updated when refresh occurs.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
19 | |
13 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
15 | |
12 | |
11 | |
9 |