Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi there
Love PowerQuery, but for some reason I can't get my head around DAX.
Anyway - I have an Employee table where I have an employment start and termination date listed. For any given period I'd like to calculate the number of days the worker has been employed, taking the start and termination dates into account.
So far I have the below, but a few issues...
1) It complains about my True/False expression. What am I doing wrong here?
2) How can I deduct 1 day from STDATE_EMP (when used in EXCL_DAYS)? Tried using DATEADD but it was expecting a column?
3) The SELECTEDRANGE is right now a single column table. Can I somehow filter this? I'm thinking a combination of VALUES and FILTER...?
Sorry that's a lot but really struggling.
Solved! Go to Solution.
The below assumes that you have a column called Is Working Day in your date table, which contains a 1 if it is a working day and 0 otherwise.
Employed days =
SUMX (
Employee,
VAR StartDate = Employee[Start date]
VAR EndDate = Employee[Termination date]
VAR NumDays =
CALCULATE (
SUM ( 'Date'[Is Working Day] ),
KEEPFILTERS ( DATESBETWEEN ( 'Date'[Date], StartDate, EndDate ) )
)
RETURN
NumDays
)
Thanks so much! Really appreciate it.
The below assumes that you have a column called Is Working Day in your date table, which contains a 1 if it is a working day and 0 otherwise.
Employed days =
SUMX (
Employee,
VAR StartDate = Employee[Start date]
VAR EndDate = Employee[Termination date]
VAR NumDays =
CALCULATE (
SUM ( 'Date'[Is Working Day] ),
KEEPFILTERS ( DATESBETWEEN ( 'Date'[Date], StartDate, EndDate ) )
)
RETURN
NumDays
)
User | Count |
---|---|
12 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
19 | |
14 | |
10 | |
7 |