DISTINCTCOUNT

Counts the number of distinct values in a column.

Quick Coach Video

What it does?

Counts the number of distinct values in a column.

Syntax

DISTINCTCOUNT( <column>)

Returns

The number of distinct values in a column.

What is the DISTINCTCOUNT Function?

The DISTINCTCOUNT function in DAX is like a savvy bouncer at a party—it counts the unique values in a column, making sure no duplicates get in! This function is perfect for seeing how many different items you have without double counting.

Try It

 

Example 1: Unique Pet Types

Imagine you run a charming pet adoption center and want to know how many unique types of pets have been adopted this month. Here’s how your pet adoption data might look:

PetAdoption Table

Pet Name

Pet Type

Luna

Cat

Socks

Cat

Vito

Cat

Kronos

Dog

Maple

Rabbit

Toby

Cat

To count the unique pet types adopted, you’d use the DISTINCTCOUNT function like this:

Unique Pet Types = DISTINCTCOUNT(PetAdoptions[Pet Type])

Total Unique Pet Types Calculation:

  • Dog (counted once)
  • Cat (counted once)
  • Rabbit (counted once)

So, how many unique pet types have been adopted? That’s a total of 3 unique pet types! 🐶🐱🐰

Example 2: Unique Movie Genres

Now, let’s say you run a movie streaming service, and you want to find out how many unique movie genres are available in your library. Here’s your movie genre data:

MovieLibrary Table

Movie Title

Genre

Data Overdrive

Sci-Fi

Byte-Sized Justice

Crime

The Code Hunter

Animation

Pixel Pursuit

Action

Data Laggan

Animation

The Quantum Heist

Crime

To count how many unique genres are in your library, you would use DISTINCTCOUNT like this:

Unique Movie Genres = DISTINCTCOUNT(MovieLibrary[Genre])

Total Unique Genres Calculation:

  • Sci-Fi (counted once)
  • Crime (counted once)
  • Animation (counted once)
  • Action (counted once)

So, how many unique movie genres do you have? That’s a total of 4 unique genres! 🎬✨

Conclusion: Count the Uniques!

The DISTINCTCOUNT function in DAX is your go-to tool for counting unique values in any dataset. Whether it’s adorable pets in your adoption center or exciting movie genres in your streaming service, DISTINCTCOUNT helps you gain valuable insights without any duplicates!

So, what are you waiting for? Let’s start counting the unique values with DISTINCTCOUNT and make data fun! 🎊🥳