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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
FrageFrosch7
Regular Visitor

Measure with Filter and Slicer

Hi everyone,

 

I’m trying to write a measure that counts the number of employees in the dim_employee table for a specific team, depending on which months are selected in the MonthShort slicer (a text column what is sorted by another Monthnumber column to garantee the right order) and which team is selected in the team slicer (also a text column).

Additionally, I have another table, fact_absence, with a column named FTE, where I want to count only the employees with a value of 1.0 in that column for the month selected in the slicer. If an employee leaves the company, their value in this column becomes null.

I’ve written a measure that works when only one month is selected. However, when multiple months are selected, it should only count the employees from the most recent month selected, not from all the months. This functionality is currently not working. Can you please help me?

 

Employeecount per team with FTE V2 =
VAR SearchText = SELECTEDVALUE(dim_employee[Team])
VAR MaxMonth =
    MAXX(
        TOPN(
            1,
            VALUES(dim_date[Monthshort]),
            dim_date[Monthshort],
            DESC
        ),
        dim_date[Monthshort]
    )
RETURN
CALCULATE(
    COUNTROWS(dim_employee),
    dim_employee[Team] = SearchText,
    FILTER(
        dim_employee,
        COUNTROWS(
            FILTER(
                fact_absence,
                fact_absence[FTE] > 0 &&  
                fact_absence[userkey] = dim_employee[itemkey] &&
                MAX(dim_date[Monthshort]) = MaxMonth 
            )
        ) > 0
    )
)
 
I'd highly appreciate your help
thanks 
2 REPLIES 2
rajendraongole1
Super User
Super User

Hi @FrageFrosch7 - issue due to measure it is handling the calculation when multiple months are selected.

we can modify the approach to calculate the most recent month in the slicer and then filter only on that month

Modified one:

Employeecount per team with FTE V2 =
VAR SearchText = SELECTEDVALUE(dim_employee[Team])
-- Get the selected team
VAR MaxMonth =
MAXX(
ALLSELECTED(dim_date[Monthshort]),
dim_date[Monthshort]
)
-- Get the most recent month selected from the slicer
RETURN
CALCULATE(
COUNTROWS(dim_employee),
dim_employee[Team] = SearchText,
FILTER(
dim_employee,
COUNTROWS(
FILTER(
fact_absence,
fact_absence[FTE] = 1 && -- Only count employees with FTE of 1
fact_absence[userkey] = dim_employee[itemkey] &&
dim_date[Monthshort] = MaxMonth -- Only consider the most recent month
)
) > 0
)
)

 

Hope this works , please check





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi rajendraongole1, 

I get the logic but unfortunately if I apply your solution I get this error

FrageFrosch7_2-1729502389967.png

 

I tested the variable in a card visual that works fine. If i select in my slicer Jan, Feb, Jul it displays Jul.

I appreciate your help!

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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