Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |