Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Good day to anyone who reads this,
I am a student taking my first steps with dax and power BI for a Data analyst internship and i've ran into a little problem I'm currently trying to figure out how to use Dax to calculate the amount of time someone got off work. These hours are calculated from the days between a start date and end date with another collumn showing how many hours per day they had off work(see excel recreation below)
I've been looking around how to get this to work with DAX and I've tried to use the following code as a first step to count the amount of days between the two dates but got no results.
Days =
DATEDIFF(
SELECTEDVALUE( TT_EMP_BOOK[TT_FROMDATE]),
SELECTEDVALUE( TT_EMP_BOOK[TT_TODATE]),
Day(
)
I've also tried looking on the DAX pages provided by microsoft temselves to see what syntax I might be putting down wrong but can't seem to figure it out its all still quite new to me.
In the end what I hope to achieve is calculating the following and putting it in a new column
Days between 01/01/2023 - 03/01/2023 = 3 * hours per day 8 = 24 hours in total
hopefully someone can lend me a hand and if so thank you in advance.
Edit note: I am using DAX studio 3.0.7 to build my DAX code before using it
Solved! Go to Solution.
This is because we are using the min value from the whole table, so this hasn't worked. Apologies. Here's a revised idea to get this to work:
daysOff =
DATEDIFF(
TT_EMP_BOOK[TT_FROMDATE],
TT_EMP_BOOK[TT_TODATE],
Day
)
This is your days between calculated column.
1. Create new column again
2. Enter this code in the column:
answer = ProductX('table', daysOff * hrsperday)
let me know, sorry for all the confusion, i think i overcomplicated this.
Edit: to correct code
I'm experiencing an issue where It doesn't want to recognise the column names with the code it seems to find the table quite alright but not the columns I made sure that they are are typed correct and everything.
Measure 1: Days off = DATEDIFF('table'[start date], 'table'[end date], DAY)
Measure 2: hoursperday = SUM('table'[hoursperday]
Measure 3: [days off] * hoursperday
Could potentially be a solution, but still send your code so i can have a look 🙂
Here it is! also the error states it cannot get a single value I did try to look into this but I dont need all the rows to be summed together as they all have different values that should be displayed. I wasn't sure of how to do that however I hope this helps you understand the issue 🙂 thanks in advance!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 12 | |
| 10 | |
| 10 | |
| 9 | |
| 8 |