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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Slicer not filtering based on measure

I am sure there is a easy change I need to make to get my slicers to work. But I am not sure what it is. 

 

This measure is counting how many employees we had active within a given timeframe. The problem is that the filter functions and all function have caused any slicer to not work with it. I am wondering what tweak I can make to have it filter with the slicers I have. 

 

VAR selectedDate =
    MAX ('calendar'[Day_Date] )
VAR result =
    CALCULATE (
        COUNTROWS ( 'Paycom EmployeeDemographics'),
        FILTER (
            FILTER ( all( 'Paycom EmployeeDemographics'), 'Paycom EmployeeDemographics'[HireDate]<= selectedDate ),
            'Paycom EmployeeDemographics'[TerminationDate] >= selectedDate
                || 'Paycom EmployeeDemographics'[TerminationDate] = BLANK ()
        )
    )
Var Rehireresult =

IF(COUNT('Paycom EmployeeDemographics'[including rehired])=2,CALCULATE (
        COUNTROWS ( 'Paycom EmployeeDemographics'),
        (FILTER (
            FILTER( ALL ( 'Paycom EmployeeDemographics'), 'Paycom EmployeeDemographics'[RehireDate] <= selectedDate),
            'Paycom EmployeeDemographics'[TerminationDate] >= selectedDate
                || 'Paycom EmployeeDemographics'[TerminationDate] = BLANK ()
        )
    )),0)
RETURN
    result+Rehireresult
 
I tried adding allselected insteard of all. It does work but it throws off all my numbers. I also tried placing a remove filters at the end of the function, but that didnt change anything. 
2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

Please try:

Measure = 
VAR selectedDate =
MAX ( 'calendar'[Day_Date] )
VAR result = 
CALCULATE (
    COUNTROWS ( 'Paycom EmployeeDemographics' ),
    FILTER (
        ALLSELECTED ( 'Paycom EmployeeDemographics' ),
        'Paycom EmployeeDemographics'[HireDate] <= selectedDate
            && (
                'Paycom EmployeeDemographics'[TerminationDate] >= selectedDate
                    || 'Paycom EmployeeDemographics'[TerminationDate] = BLANK ()
            )
    )
)
Var Rehireresult =
IF (
    COUNT ( 'Paycom EmployeeDemographics'[including rehired] ) = 2,
    CALCULATE (
        COUNTROWS ( 'Paycom EmployeeDemographics' ),
        FILTER (
            ALLSELECTED ( 'Paycom EmployeeDemographics' ),
            'Paycom EmployeeDemographics'[RehireDate] <= selectedDate
                && (
                    'Paycom EmployeeDemographics'[TerminationDate] >= selectedDate
                        || 'Paycom EmployeeDemographics'[TerminationDate] = BLANK ()
                )
        )
    ),
    0
)
RETURN
    result+Rehireresult

If this does not work, could you consider providing a sanitized file for testing? That would be helpful.

Best Regards,
Gao

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

Anonymous
Not applicable

Thank you for the response! It does make the slicers work but the numbers change drastically by about 200. I am not sure why it does that.

Here is what the graph looks like:

 

Screenshot 2022-11-18 145618.png

 

Here is some of my data and how its setup:

 

Screenshot 2022-11-18 145747.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.