Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi All,
Looking to create a measure which tells me which employees are present at a certain month and year.
I have a "Persons" Table with the following fields: Full Name, First Name, Last Name, Start Date, End Date.
I have a "Calendar" table with the following fields: Date, Month, Year, YearMonth.
Calendar is linked to Persons via an Active One to Many Relationship to Start Date. And a non-active relationship between date and End Date.
How I can calculate how many staff at present at each month and year using this information.
As the result I'm getting at the moment are only returning data for the month where people have a start date.
For Example Aiden Sally's Count should appear from Jun 2018 - March 2023.
For Example Yuliia Susan's Count should appear from Jun 2022 - March 2023.
try
Active Employees =
VAR MinDate =
MIN ( 'Date'[Date] )
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR Result =
CALCULATE (
COUNTROWS ( 'Staff' ),
'Staff'[Start date] <= MaxDate
&& (
'Staff'[End date] >= MinDate
|| ISBLANK ( 'Staff'[End date] )
)
)
RETURN
Result
Hi Johnt75,
The dax you provided only produces figures for when the employee starts.
For Example Aiden Sally would only appear in June 2018 and not in future months.
Try
Active Employees =
VAR MinDate =
MIN ( 'Date'[Date] )
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR Result =
CALCULATE (
COUNTROWS ( 'Staff' ),
REMOVEFILTERS ( 'Staff'[Start date], 'Staff'[End date] ),
'Staff'[Start date] <= MaxDate
&& (
'Staff'[End date] >= MinDate
|| ISBLANK ( 'Staff'[End date] )
)
)
RETURN
Result
I'm getting this error now appearing with this updated one.
"the expression refers to multiple columns. Multiple columns cannot be converted to scalar value."
can you post a shot of the full measure so we can see where the red lines are and see what exactly it is complaining about
Please see attached full shot of the measure.
I basically would like to get the figures below. So during December 2022 I had 179 Employees with a start date equal or less than 31/12/2022, and a leaving date equal or less than 31/12/2022 or blank. Then in Jan 2023 184. Etc etc.
You're missing the COUNTROWS from the CALCULATE statement
I've just re-added it and the numbers are still the same as the first statement.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
17 | |
10 | |
10 | |
8 | |
6 |
User | Count |
---|---|
20 | |
18 | |
16 | |
13 | |
10 |