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

View all the Fabric Data Days sessions on demand. View schedule

Reply
justinbouchard
Frequent Visitor

Counting first instance of a number in a column

Hi everyone,

 

I'm working with a student dataset where it shows all students who register in a given term. It also incldues the term the student is admitted. What I am trying to do is get a number of how many students were admitted in a given term.

Here is a sample dataset

Studend IDTerm of RegistrationTerm Admitted
123Fall 2019Fall 2018
124Fall 2019Fall 2018
125Fall 2019Fall 2019
123Winter 2020Fall 2018
124Winter 2020Fall 2018
125Winter 2020Fall 2019
123Fall 2021Fall 2018
124Fall 2021Fall 2018
125Fall 2021Fall 2019

 

If I filter down so only one term of registration is showing this is simple distinct count. But when i have multiple terms of regisrationg showing it will repeatedly count the values in the column of term admitted. 

 

I know i can run separate measures for each specific admit term, but I'm looking to have one foruma so i can graph this.

 

Whats the best way to do this with dax?

 

Thank you,

 

Justin

1 ACCEPTED SOLUTION

Dear @Syk 

Why use SUMMARIZE when simple DISTINCT/VALUES is enough? Your code can be written simpler:

 

Students =
SUMX(
    DISTINCT( Students[Term of Registration] ),
    CALCULATE( 
        DISTINCTCOUNT( Students[Studend ID] ) 
    )
)

 

and you forgot CALCULATE.

On the other hand, this is precisely what @justinbouchard did not want because your code counts a student many times on the total row.

View solution in original post

4 REPLIES 4
daXtreme
Solution Sage
Solution Sage

What you say is simply not true:

But when i have multiple terms of regisrationg showing it will repeatedly count the values in the column of term admitted.

Distinct count will count any student only once in any data set. That's how distinct count works.

Yes, I was unclear on that. I guess I want to do a distinct count within a distinct count

Syk
Super User
Super User

Try this...

Students =
SUMX (
    SUMMARIZE ( Students, Students[Term of Registration] ),
    DISTINCTCOUNT ( Students[Studend ID] )
)

Syk_0-1668798745794.png

 

Dear @Syk 

Why use SUMMARIZE when simple DISTINCT/VALUES is enough? Your code can be written simpler:

 

Students =
SUMX(
    DISTINCT( Students[Term of Registration] ),
    CALCULATE( 
        DISTINCTCOUNT( Students[Studend ID] ) 
    )
)

 

and you forgot CALCULATE.

On the other hand, this is precisely what @justinbouchard did not want because your code counts a student many times on the total row.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors