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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Filtering duplicate values in measure

Hi all,

 

I have a table like this:

 

Employee #Job Information: DateLocationDivisionDepartmentJob TitleJob Information end date
101/01/2018USAUSSalesSales Expert01/01/2019
101/01/2018USAUSSalesSenior Sales Expert 
201/01/2018GermanyEuropeSalesSales Expert01/01/2019
201/01/2018GermanyEuropeSalesSenior Sales Expert05/01/2019

 

Job information: date; blank means the person is still active in this role.

 

I am creating a visual to see the number of people per location in years, and to calculate the numbers, I use the following measure:

 

% isDateActiveEmployeeDistinctCount = CALCULATE(
DISTINCTCOUNT('_FactJobInformationUnion'[Employee #]),

FILTER(
_FactJobInformationUnion,
AND(
AND(
_FactJobInformationUnion[Job Information: Date] <> BLANK(),
_FactJobInformationUnion[Job Information: Date] <= MAX(_DimDate[Date])
),
OR(
_FactJobInformationUnion[Job Information: EndDate] = BLANK(),
_FactJobInformationUnion[Job Information: EndDate] >= MIN(_DimDate[Date])
)
)
),
FILTER(
__EmployementDates,
OR(
__EmployementDates[Termination Date] > MIN(_DimDate[Date]),
__EmployementDates[Termination Date] = BLANK()
)
 
)
)
 
However, as you can see, if one person changed roles within a year (let's say in 2019), my formula calculates this person as two, taking both roles into consideration. Therefore, I am trying to find a way to insert one step in the formula, which will give me a distinct result per person, showing only the latest role (if this person is still active, the formula needs to pick the data with blank job information: date, if it's not active, then it should pick the most recent date in the job information: date field).
 
I hope I am able to explain the situation and the issue.
 
Appreciate your support on this.
 
Best regards,
Ugur
1 REPLY 1
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

Not very clear about your requirement, maybe you can modify your measure like below:

% isDateActiveEmployeeDistinctCount =
CALCULATE (
    DISTINCTCOUNT ( _FactJobInformationUnion[Employee #] ),
    FILTER (
        ALLEXCEPT ( _FactJobInformationUnion, _FactJobInformationUnion[Employee #] ),
        AND (
            AND (
                _FactJobInformationUnion[Job Information: Date] <> BLANK (),
                _FactJobInformationUnion[Job Information: Date] <= MAX ( _DimDate[Date] )
            ),
            OR (
                _FactJobInformationUnion[Job Information: EndDate] = BLANK (),
                _FactJobInformationUnion[Job Information: EndDate] >= MIN ( _DimDate[Date] )
            )
        )
    ),
    FILTER (
        __EmployementDates,
        OR (
            __EmployementDates[Termination Date] > MIN ( _DimDate[Date] ),
            __EmployementDates[Termination Date] = BLANK ()
        )
    )
)

Community Support Team _ Jimmy Tao

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

 

Helpful resources

Announcements
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 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.