Forum Discussion
fabiocovre
Advocate I
8 years agoCalculate Exposed Employees in a Period
Hello, I have two databases: Employees and Expenditures. They are connected by an ID field. The Employees database contains the StartDate and the Enddate in the company The Expenses database...
fabiocovre
Advocate I
8 years agoHey v-ljerr-msft
Sorry, this is the original file. But the data structure is the same.
Thank you! :smileyhappy:
Ashish_Mathur
Super User
8 years ago- Ashish_Mathur8 years ago
Super User
Hi fabiocovre
Try this edited measure2 formula
=if(HASONEVALUE(Expenditures[PaymentMonth]),SUMX(Employees,[Measure]),SUMX(SUMMARIZE(ALLSELECTED(Expenditures[PaymentMonth]),[PaymentMonth],"ABCD",SUMX(Employees,[Measure])),[ABCD]))
Hope this helps.
- 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