Forum Discussion
Calculate Exposed Employees in a Period
Hey v-ljerr-msft,
Almost there... I think this picture below represents what I need. I'd like to sum the number of exposed employees by month and then, be able to have differents views with this amount, for example, by sex, by age group etc...
You are helping me a lot. Thank you very much for your time!
Hi fabiocovre,
It seems that the sample data is now different from what you have shared in the original post. Could you share your current pbix file, so that I can further assist on the issue? :smileyhappy:
Regards
- fabiocovre8 years ago
Advocate I
Hey v-ljerr-msft
Sorry, this is the original file. But the data structure is the same.
Thank you! :smileyhappy:
- Ashish_Mathur8 years ago
Super User
- fabiocovre8 years ago
Advocate I
I'm sorry if I wasn't clear in my explanation.
So, in this example, my difficulty is to find the number 22.677 instead of 2990. This value is obtained by the cumulative sum of Measure2 monthly (3425 + 3321 +... + 3041).
The other value, 59,09, is easier... it's obtained by the total expenses in the period (1.340.026,29) divided by 22.677.
To get until here, I used the formulas below that v-ljerr-msft gave me.
Measure = VAR minSelectedPaymentMonth = MIN ( Expenditures[PaymentMonth] ) VAR maxSelectedPaymentMonth = MAX ( Expenditures[PaymentMonth] ) VAR startDate = MAX ( Employees[StartDate] ) VAR endDate = MAX ( Employees[EndDate] ) RETURN IF ( maxSelectedPaymentMonth >= startDate && maxSelectedPaymentMonth <= endDate && minSelectedPaymentMonth <= startDate, DATEDIFF ( startDate, maxSelectedPaymentMonth, MONTH )+1, IF ( maxSelectedPaymentMonth >= startDate && maxSelectedPaymentMonth <= endDate && minSelectedPaymentMonth >= startDate, DATEDIFF ( minSelectedPaymentMonth, maxSelectedPaymentMonth, MONTH )+1, IF ( maxSelectedPaymentMonth >= endDate && minSelectedPaymentMonth <= startDate, DATEDIFF ( startDate, endDate, MONTH )+1, IF ( maxSelectedPaymentMonth >= endDate && minSelectedPaymentMonth >= startDate && minSelectedPaymentMonth <= endDate, DATEDIFF ( minSelectedPaymentMonth, endDate, MONTH )+1 ) ) ) ) + 0Measure 2 = SUMX( Employees , [Measure] )
Thank you for your time and help!
Fabio