Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
eyeekit
Frequent Visitor

Applying filter on measure not working on visual piechart

I have a table XXX which has 4 fields:

ID, Gender, Startdate, Enddate

I created a measure YesNo which returns 0 or 1 when a selected date from a slicer lies beween startdate and enddate:

 

Measure YesNo =
var _datum=SELECTEDVALUE('Peildata'[datum])           
return
if (
SELECTEDVALUE('Table'[startdate]) <= _datum
&&
SELECTEDVALUE('Table'[enddate]) >= _datum,
1,0)

 

When i present the results in a table visual it is correct

IDGenderYesNo
1M1
2M1
3M0
4F1
5F0

 

When I want to create a piechart visual which counts males/females, it gives me 3M and 2F, that is also correct.

But when I add the measure YesNo in the piechart visual filtering with YesNO is 1 and I expected to see 2M and 1 F

but my visual totally blanks and dissapears with no results

What does this not work?

 

 

 

 

 

 
 
1 ACCEPTED SOLUTION

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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.

 

vyaningymsft_0-1700555133032.png

 

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.