Forum Discussion
Filtering based on parent grouping
Hi, v-yueyunzh-msft
Here is a set of sample data for the Position table.
| EmployeeCode | EmployeeGroupId | EmployeeStatusId | FiscalPeriodId | CompanyId | Id |
| 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 | 2 |
| 2 | 1 | 2 | 1 | 1 | 3 |
| 2 | 2 | 1 | 1 | 1 | 4 |
| 3 | 1 | 2 | 1 | 1 | 5 |
| 4 | 1 | 1 | 1 | 1 | 6 |
| 5 | 1 | 1 | 1 | 1 | 7 |
| 5 | 1 | 2 | 1 | 1 | 8 |
| 6 | 1 | 2 | 1 | 1 | 9 |
| 1 | 2 | 2 | 1 | 1 | 10 |
The results from the visual for this sample data look like this. The slicer should be filtering out employee group 2.
DistinctEmployeeCount is produced by this measure.
DistinctEmployeeCount =
CALCULATE(
COUNT(PositionSample[EmployeeCode]),
FILTER(
PositionSample,
RELATED(Headcount[EmployeeStatusCount]) = 1
)
)
And finally, here are the expected results.
Thanks for your help!
Hi, ruiner
Thanks for your quick reponse!
I'm very sorry that there is no way to understand your arithmetic logic.
Accoridng to the sample data , when you filter the [employee group]=2 , it shows the table like this:
And then the [DistinctEmploymentCount] measure seems to calculate the sum of the "EmployeeCode" where the [EmployeeStatusCount]=1 in the 'Headcount' Table.
And from your sample data , i still do not understand how to get the table when filter the [employee group]=2?
Can you give me the sample data in 'Headcount' Table and explain the detailed calculation for the table you want to get in the end?
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly