Forum Discussion

eyeekit's avatar
eyeekit
Frequent Visitor
2 years ago
Solved

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:   Measur...
  • eyeekit's avatar
    eyeekit
    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