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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Redpandas
Regular Visitor

Slicer doesn‘t work for my measure

I have a  “Date” table (each day in 2022) and "employ" table (employee number, dept, onboard date, turnover date).

I would like to calculate the active employee number in 2022 each month.

so here I create a measure as below but find the number does not change with dept Slicer

 

Active employee= VAR date_=MAX('Date'[date])

Return

Calculate(

       countrows('employ'),

       FILTER(

              ALL(’employ'),

              'employe'[onboard date]<=date_&&('employe'[turnover date]>date_||'employe'[turnover date]=BLANK())

        )

)

 

 

Really appreciate any response, thank you.

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi  @Redpandas ,

As checked the formula of your measure, it applied ALL function. And it returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. Please update the formula of the measure as below and check if it can get the correct result...

Active employee =
VAR date_ =
    MAX ( 'Date'[date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'employ' ),
        FILTER (
            ALLSELECTED ( 'employ' ),
            'employe'[onboard date] <= date_
                && (
                    'employe'[turnover date] > date_
                        || 'employe'[turnover date] = BLANK ()
                )
        )
    )

 

If the above one can't help you get the desired result, please provide some sample data in your table 'employ' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi  @Redpandas ,

As checked the formula of your measure, it applied ALL function. And it returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. Please update the formula of the measure as below and check if it can get the correct result...

Active employee =
VAR date_ =
    MAX ( 'Date'[date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'employ' ),
        FILTER (
            ALLSELECTED ( 'employ' ),
            'employe'[onboard date] <= date_
                && (
                    'employe'[turnover date] > date_
                        || 'employe'[turnover date] = BLANK ()
                )
        )
    )

 

If the above one can't help you get the desired result, please provide some sample data in your table 'employ' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you Rena for giving me hint of replacing ALL(’employ'). And I tried Keepfilter and worked. ALLSELECTED ( 'employ' ) work for slicers but doesn‘t know for table with separated “Dept”.

JorgePinho
Solution Sage
Solution Sage

Try this instead:

 

Active employee= VAR date_=MAX('Date'[date])

Return

Calculate(

       countrows('employ'),

       'employe'[onboard date]<=date_&&('employe'[turnover date]>date_||'employe'[turnover date]=BLANK())

)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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