Forum Discussion
Measure dependent on date
- 6 years ago
Just specify an aggregation such as max to get a single result.
- 6 years ago
Hey v-chuncz-msft, that is exactly what I meanwhile found myself to work perfectly.
Just for reasons of completeness the result looks like that:
WorkingHours = IF(MAX(Plan[DATE])<MAX(Employee[HireDate]);
CALCULATE(SUM(Employee[WorkingHours];
FILTER(Employee;Employee[Employee]<>"NewHireName"));
CALCULATE(SUM(Employee[WorkingHours]))
EmployeeCount = IF(MAX(Plan[DATE])<MAX(Employee[HireDate]);
CALCULATE(DISTINCTCOUNT(Employee[Employee]);
FILTER(Employee;Employee[Employee]<>"NewHireName"));
DISTINCTCOUNT(Employee[Employee]))
WorkDayDount = CALCULATE (
DISTINCTCOUNT(Plan[Date]);
FILTER ('Plan';'Plan'[Weekday] <= 5))
PayedWorkTime = Employee[WorkingHours] / Employee[EmployeeCount] * Plan[WorkDayDount]
Thanks everyone for supporting me!
I could introduce a "hire date" to make a distinct count based on that. Is that what you mean? Will give it a try and get back here than.
MFelix Your formula looks good and I'd like to try it but two things
1. Power BI tells me that SELECTED is invalid - is there something missing or do I do something wrong?
2. I can't use "Table[DATE]" in a measure - how can I get round this?
Thanks for your feedback! Highly appreciated.
Its SELECETEDVALUE sorry for the error.
And tha Table[Date] should be replaced by the name of your date column on your model. Since I did not know what was that I made a generic name.
- flex996 years agoHelper I
Hey v-chuncz-msft, that is exactly what I meanwhile found myself to work perfectly.
Just for reasons of completeness the result looks like that:
WorkingHours = IF(MAX(Plan[DATE])<MAX(Employee[HireDate]);
CALCULATE(SUM(Employee[WorkingHours];
FILTER(Employee;Employee[Employee]<>"NewHireName"));
CALCULATE(SUM(Employee[WorkingHours]))
EmployeeCount = IF(MAX(Plan[DATE])<MAX(Employee[HireDate]);
CALCULATE(DISTINCTCOUNT(Employee[Employee]);
FILTER(Employee;Employee[Employee]<>"NewHireName"));
DISTINCTCOUNT(Employee[Employee]))
WorkDayDount = CALCULATE (
DISTINCTCOUNT(Plan[Date]);
FILTER ('Plan';'Plan'[Weekday] <= 5))
PayedWorkTime = Employee[WorkingHours] / Employee[EmployeeCount] * Plan[WorkDayDount]
Thanks everyone for supporting me!