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
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
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 community update carousel

Fabric Community Update - June 2025

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