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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
MichalF1986
New Member

Count of ID joining selected dataset

Hi,
I'm trying to get the below result:
In the dataset where the user can put filters on whatever dimensions/combination of dimensions I need to find the first appear of Employee and could how many those "first appear" are per month. For example:

 

My full Dataset:

DateNameCategoryJob Type
1-1-2020HarryOne11
1-2-2020HarryOne11
1-3-2020HarryOne11
1-4-2020HarryTwo11
1-5-2020HarryTwo11
1-6-2020HarryTwo11
1-7-2020HarryTwo22
1-8-2020HarryTwo22
1-9-2020HarryTwo22
1-10-2020HarryThree22
1-11-2020HarryThree22
1-12-2020HarryThree22
1-1-2020SallyOne22
1-2-2020SallyOne22
1-3-2020SallyOne22
1-4-2020SallyOne22
1-5-2020SallyOne22
1-6-2020SallyOne22
1-7-2020SallyOne22
1-8-2020SallyThree22
1-9-2020SallyThree22
1-10-2020SallyThree22
1-11-2020SallyThree11
1-12-2020SallyThree11

 

Here I sould get 2 for 1-1-2020 and 0 for the rest.

 

But when User will put filter on Category "One and "three" and Job Type "22":

DateNameCategoryJob Type
1-10-2020HarryThree22
1-11-2020HarryThree22
1-12-2020HarryThree22
1-1-2020SallyOne22
1-2-2020SallyOne22
1-3-2020SallyOne22
1-4-2020SallyOne22
1-5-2020SallyOne22
1-6-2020SallyOne22
1-7-2020SallyOne22
1-8-2020SallyThree22
1-9-2020SallyThree22
1-10-2020SallyThree22

 

I should get 1 for 1-10-2020 (Harry) ,1 for 1-1-2020 (Sally) and 0 for the rest. 


The easiest way to do this would be to use lookupvalue on date +Name, but lookupvalue is a custom column function so is not dynamic/reacting to filter change.
My second idea was to create a key and key - 1 month which would be a concatenation of the dimensions where the user filtered SOMETHING, and it worked... almost. it was also caching change in dimension, not only "joining it" (first appearance)

 

Does anyone have and idea how to resolve above problem?

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1666084708158.png

 

 

Jihwan_Kim_0-1666084685377.png

 

 

First appear measure: =
VAR _firstappeardatebyname =
    ADDCOLUMNS (
        DISTINCT ( 'Name'[Name] ),
        "@firstappeardate",
            CALCULATE (
                MIN ( Data[Date] ),
                FILTER ( ALLSELECTED ( Data ), Data[Name] = EARLIER ( 'Name'[Name] ) )
            )
    )
RETURN
    COUNTROWS (
        FILTER ( _firstappeardatebyname, [@firstappeardate] = MAX ( 'Calendar'[Date] ) )
    ) + 0

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1666084708158.png

 

 

Jihwan_Kim_0-1666084685377.png

 

 

First appear measure: =
VAR _firstappeardatebyname =
    ADDCOLUMNS (
        DISTINCT ( 'Name'[Name] ),
        "@firstappeardate",
            CALCULATE (
                MIN ( Data[Date] ),
                FILTER ( ALLSELECTED ( Data ), Data[Name] = EARLIER ( 'Name'[Name] ) )
            )
    )
RETURN
    COUNTROWS (
        FILTER ( _firstappeardatebyname, [@firstappeardate] = MAX ( 'Calendar'[Date] ) )
    ) + 0

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.