Forum Discussion
Applying filter on measure not working on visual piechart
- 2 years ago
Hi Yang,
Thank you very much. It puts me in the right direction. The solution is not have 2 separate measures
for the 2 genders, but teh folowing did the job:
The folowing measure works perfect:
Measure Headcount = CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Startdate] <= SELECTEDVALUE ( 'Peildata'[datum] ) && 'Table'[Enddate] >= SELECTEDVALUE ( 'Peildata'[datum] ) )After further analysis of my data I discover that the ID field has duplicates, so to count only the
distinct values I wrote the folowing measure and it works just perfect!
Headcount =
CALCULATE
(
DISTINCTCOUNT(Tabel[ID]),
FILTER(Tabel,
Tabel[Startdate] <= SELECTEDVALUE (Peildata[Datum]) &&
Tabel[Enddate] >= SELECTEDVALUE (Peildata[datum])
)
)Thank you very much for your assistence, much appreciated!!
Best regards,
Etiënne
Hi, eyeekit
May I ask if this is the expected output you are looking for? Based on your description, I have created two measures to achieve the effect you are looking for. Following picture shows the effect of the display.
Measure M =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Startdate] <= SELECTEDVALUE ( 'Peildata'[datum] )
&& 'Table'[Enddate] >= SELECTEDVALUE ( 'Peildata'[datum] )
&& 'Table'[Gender] = "M"
)
Measure F =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Startdate] <= SELECTEDVALUE ( 'Peildata'[datum] )
&& 'Table'[Enddate] >= SELECTEDVALUE ( 'Peildata'[datum] )
&& 'Table'[Gender] = "F"
)
If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi Yang,
Thank you very much. It puts me in the right direction. The solution is not have 2 separate measures
for the 2 genders, but teh folowing did the job:
The folowing measure works perfect:
Measure Headcount =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Startdate] <= SELECTEDVALUE ( 'Peildata'[datum] )
&& 'Table'[Enddate] >= SELECTEDVALUE ( 'Peildata'[datum] )
)
After further analysis of my data I discover that the ID field has duplicates, so to count only the
distinct values I wrote the folowing measure and it works just perfect!
Headcount =
CALCULATE
(
DISTINCTCOUNT(Tabel[ID]),
FILTER(Tabel,
Tabel[Startdate] <= SELECTEDVALUE (Peildata[Datum]) &&
Tabel[Enddate] >= SELECTEDVALUE (Peildata[datum])
)
)
Thank you very much for your assistence, much appreciated!!
Best regards,
Etiënne