Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Dear all,
I´m having difficulties in my dax formula using CALCULATE and COUNTROWS as described below.
I have two tables that contains information from employees:
1: SAP_HR-VW_INTEGRANTE_INFO has distinct employees' id values, with date of dismissal (that I´m interested)
2: SAP_HR-VW_Z_FOLHA has multiple employees' id values, with all the earnings each month of the year.
I want to count how many active employees I have for each period.
I´m trying
Count of Active Employees =
CALCULATE(
COUNTROWS('SAP_HR-VW_Z_FOLHA');
FILTER('SAP_HR-VW_INTEGRANTE_INFO';
'SAP_HR-VW_INTEGRANTE_INFO'[Date of Dismissal] < STARTOFMONTH('SAP_HR-VW_Z_FOLHA'[Period of earnings (date)])
|| 'SAP_HR-VW_INTEGRANTE_INFO'[Date of Dismissal] > ENDOFMONTH('SAP_HR-VW_Z_FOLHA'[Period of earnings (date)])
|| 'SAP_HR-VW_INTEGRANTE_INFO'[Date of Dismissal] = BLANK()
)
)
But it´s not giving me the correct number. I´m guessing it´s not getting the "Period of earnings" for each line.
Thank you,
Eduardo
Solved! Go to Solution.
Dear Tom,
Thank you very much. Just by testing ENDOFMONTH and STARTOFMONTH separately I was able to identify the problem.
The content of "Period of earnings (date)" was the first of every month (01/01/2017, 02/01/2017, etc). I needed to get the first and last date of the month of that year. I noticed I missed the ".[Date]". After I included it, I was able to see in a separate table the value, and then into my expression and it worked.
Count Test (End of Month) =
CALCULATE(
ENDOFMONTH('SAP_HR-VW_Z_FOLHA'[Period of earnings (date)].[Date])
)
Best regards,
Eduardo
Hey,
what is the relationship between your both tables, with this I mean the relationship in your Power BI data model
SAP_HR-VW_INTEGRANTE_INFO
and
SAP_HR-VW_Z_FOLHA
I have to admit that I'm not familiar with SAP data, but what is the exact content of the column "Period of earnings (date)"?
Did you check the result of your expression by just using
CALCULATE(
STARTOFMONTH(...)
)
and
CALCULATE(
ENDOFMONTH(...)
)
Regards
Dear Tom,
Thank you very much. Just by testing ENDOFMONTH and STARTOFMONTH separately I was able to identify the problem.
The content of "Period of earnings (date)" was the first of every month (01/01/2017, 02/01/2017, etc). I needed to get the first and last date of the month of that year. I noticed I missed the ".[Date]". After I included it, I was able to see in a separate table the value, and then into my expression and it worked.
Count Test (End of Month) =
CALCULATE(
ENDOFMONTH('SAP_HR-VW_Z_FOLHA'[Period of earnings (date)].[Date])
)
Best regards,
Eduardo
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |