Power BI DAX Count [15 real examples]

In the Power Bi tutorial, we will learn how to count the row values presented in the data table using the Power Bi Count function in Power Bi.

In a recent Power Bi project, I had to calculate the row count value for the data table using the Power BI Count aggregation function. Also covered below mentioned topics:

  1. Power BI DAX count
  2. Power BI DAX counts distinct
  3. Power BI DAX count slicer selection
  4. Power BI DAX count group by
  5. Power BI DAX count blank
  6. Power BI DAX count and filter
  7. Power BI DAX count boolean
  8. Power BI DAX count greater than
  9. Power BI DAX counts all
  10. Power BI DAX count based on condition
  11. Power BI DAX count distinct if
  12. Power BI DAX count contains
  13. Power BI DAX count duplicates
  14. Power BI DAX count by date
  15. Power BI DAX count by month
  16. Power BI DAX count days

Power BI DAX count

Let us see how we can count the row values using the Power Bi Dax Count function in Power BI.

Power Bi Dax count function, which Counts the rows presented in the specified column that includes non-blank values.

The syntax for the COUNT function in Power BI:

= COUNT(<column>)

In this example, we are going to use the sales table data to count the values presented in the data table using the Power Bi Count function in Power BI.

Power BI DAX count
Power BI DAX count
  • Load data into the Power Bi desktop using the get data option, Select the new measure option from the ribbon under the Home tab and apply the below-mentioned formula.
Product Count = COUNT(Sales_Table[Product Name]) 

Where,

  1. Product Count = New Measure name
  2. COUNT = Function name
  3. Sales_Table = Table Name
  4. Product Name = Column Name
  • Now in the report section, select the table visual and card visual. In the table visually drag and drop the Product Name and Sales fields from the field pane.
  • And in the card visual drag and drop the created measure value to display the row count presented in the data table.
  • The screenshot below displays the row count value presented in the data table.
Power BI DAX count example
Power BI DAX count example

This is how to count the row values using the Power Bi Dax Count function in Power BI.

Check out Power BI Dax Min Filter

Power BI DAX counts distinct

Let us see how we can count the distinct row values using the Power Bi Dax distinct Count function in Power BI.

Distinct row count values return the unique values from the data table for the mentioned column,

  • Load data into the Power Bi desktop, Select the new measure option from the ribbon under the Home tab and apply the below-mentioned formula.
Product Count = DISTINCTCOUNT(Sales_Table[Product Name]) 

Where,

  1. Product Count = New Measure name
  2. DISTINCT COUNT = Function name
  3. Sales_Table = Table Name
  4. Product Name = Column Name
  • Now in the report section, select the table visual and card visual. In the table visually drag and drop the Product Name and Sales fields from the field pane.
  • And in the card visual drag and drop the Created measure value to display the distinct count values for the product name column presented in the data table.
  • The screenshot below displays the distinct count value presented in the data table for the mentioned column name.
Power BI DAX counts distinct
Power BI DAX counts distinct

This is how to count the distinct row values using the Power Bi Dax distinct Count function in Power BI.

Power BI DAX count slicer selection

Let us see how we can count the row value based on the slicer selection using the Power Bi Dax count function in Power Bi.

  • Open the Power Bi desktop and load the data using the get data option, Select the new measure option from the ribbon under the Home tab and apply the below-mentioned formula.
Count based on slicer selection = COUNT(Sales_Table[Product Name])

Where,

  1. Count based on slicer selection = New Measure name
  2. COUNT = Function name
  3. Sales_Table = Table Name
  4. Product Name = Column Name
  • Now in the report section, select the slicer visual and card visual. In the slicer visual drag and drop the Product name from the field pane.
  • And in the card visual drag and drop the created measure value to display the count values for the product name column presented in the data table.
  • The screenshot below displays the count value based on the slicer selection in the data table. By default, it displays the default row counts value.
Power BI DAX count slicer selection
Power BI DAX count slicer selection
  • Now if we select any products from the slicer visual, then it will display the number of products presented in the data table.
  • Here in the slicer visual, I have selected the product name called Dish Washer, and in the card visual it displays the product count value.
Power BI DAX count slicer selection example
Power BI DAX count slicer selection example

In the same way, if we select different products from the slicer visual, the card visual displays the selected product count value.

Example of Power BI DAX count slicer selection
Example of Power BI DAX count slicer selection

This is how to count the row value based on the slicer selection using the Power Bi Dax count function in Power Bi.

Check out, Power BI DAX Min Date from Text

Power BI DAX count group by

Let us see how we can count the row value by grouping the values presented in the data table in Power Bi.

  • Load data into the Power Bi desktop, Select the new measure option from the ribbon under the Home tab and apply the below-mentioned formula.
Group by = CALCULATE( COUNTROWS( Sales_Table ),
    Sales_Table[Customer Location] = "Florida",
    ALLEXCEPT( Sales_Table, Sales_Table[Product Name])
)

Where,

  1. Group by = New Measure name
  2. COUNT = Function name
  3. Sales_Table = Table Name
  4. Product Name = Column Name

Now in the data table, filter the mentioned customer location column as below to check the product count manually:

Power BI DAX count group by
Power BI DAX count group by
  • Now in the report section, select the table visual and card visual. In the table visual select the Product Name, Customer Location, and the created Group by measure field from the field pane.
  • In the card visual drag and drop the created measure value to display the count values for the product name column presented in the data table by grouping the customer location.
  • The screenshot below groups the value and displays the product count value for the mentioned customer location.
Power BI DAX count group by example
Power BI DAX count group by example

This is how to count the row value by grouping the values presented in the data table in Power Bi.

Power BI DAX count blank

Here we will count the blank values presented in the column in the data table in Power Bi.

In this example, we will count the blank values for the Discount column presented in the table data using the Count function in Power Bi.

  • Load data into the Power Bi desktop, Select the new measure option from the ribbon under the Home tab and apply the below-mentioned formula.
Blank Values Count = COUNTBLANK(Sales_Table[Discount])

Where,

  1. Blank Values Count = New Measure name
  2. COUNTBLANK = Function name
  3. Sales_Table = Table Name
  4. Discount = Column Name

Now in the data table filter the mentioned discount column below to check the count manually:

Power BI DAX count blank
Power BI DAX count blank
  • Now in the report section, select the table visual and card visual. In the table visual select the Product Name and the created blank value count measure fields from the field pane.
  • In the card visual drag and drop the created measure value to display the blanks count values for the discount column presented in the data table.
  • The screenshot below displays the blank count value for the mentioned discount column in the data table.
Example of Power BI DAX count blank
Example of Power BI DAX count blank

This is how to count the blank values presented in the column in the data table in Power Bi.

Check out, Power bi Dax Min Date Add

Power BI DAX count and filter

Here we will see how we will filter the column based on condition by using the Power Bi Filter() function and then to count the row values, we will use the Power Bi count rows function in Power Bi.

  • Load the data using the get data option on the power bi desktop. Click on the new measure from the ribbon and apply the below formula to count rows for the product name called Laptop.
Count with Filter = COUNTROWS(FILTER(Sales_Table,Sales_Table[Product Name]="laptop"))

Where,

  1. Count with Filter = New Measure name
  2. COUNTROWS = Function name
  3. Sales_Table = Table Name
  4. Product Name = Column Name
  • In the Power Bi report section, select the table visual and card visual. In the table visual select the Product Name, sales, and customer location fields from the field pane.
  • In the card visual drag and drop the created measure value to display the filtered count values.
  • The screenshot below displays the filtered count value for the mentioned product name in the data table.
Power BI DAX count and filter
Power BI DAX count and filter

This is how to filter the column based on condition by using the Power Bi Filter() function.

Power BI DAX count boolean

Let us see how we can find and count the boolean values presented in the data table in Power Bi.

In this example we will count the boolean value, if the discount column presented in the table data has a zero value then it displays a true value or else a false value.

  • Load data into the Power Bi desktop, Select the new column option from the ribbon under the Home tab, and apply the below-mentioned formula.
Boolean = IF((Sales_Table[Discount])=BLANK(),TRUE(),FALSE())

Where,

  1. Boolean = New column name
  2. Sales_Table = Table Name
  3. Discount = Column Name
  4. Blank = Function Name
  • In the below screenshot, you can see that the new column displays the boolean value as true or false based on the condition applied.
Power BI DAX count boolean
Power BI DAX count boolean

This is how we can find and count the boolean values presented in the data table in Power Bi.

Read Power BI DAX Min Date Sum

Power BI DAX count greater than

Let us see how we can find the row count values where the sales are greater than the mentioned value in Power Bi.

In this example, we will calculate the row count value for the sales column and if the sales value is greater than 0 it displays the count value.

  • Load the data using get data. Then click on the new measure to count the sales which are greater than 0. Then write the below measure:
Sales Count = Calculate ( Count (Sales_Table[Sales]), 'Sales_Table'[Sales] > 0)

Where,

  1. Sales Count = New measure name
  2. Sales_Table = Table Name
  3. Sales = Column Name
  • In the Power Bi report section, select the table visual and card visual. In the table visual select the Product Name, sales, and customer location fields from the field pane.
  • In the card visual drag and drop the created measure value to display the sales value count that is greater than 0.
  • In the below screenshot, you can see that the card visually displays the sales count value.
Power BI DAX count greater than
Power BI DAX count greater than

This is how to find the row count values where the sales are greater than the mentioned value in Power Bi.

Power BI DAX counts all

Let us see how we can count all the row values using the Power Bi Dax Count all function in Power BI.

In this example, we are going to count all the sales values presented in the data table using the Power Bi Count function in Power BI.

  • Load data into the Power Bi desktop, Select the new measure option from the ribbon under the Home tab, and apply the below-mentioned formula.
Count ALL = Calculate(Countrows(Sales_Table),
    All(Sales_Table[Product Name]) )

Where,

  1. Count ALL = New Measure name
  2. Count rows = Function name
  3. Sales_Table = Table Name
  4. Product Name = Column Name
  • Now in the report section, select the table visual and card visual. In the table visually drag and drop the Product Name, Sales, and customer location fields from the field pane.
  • And in the card visual drag and drop the created measure value to display the row count presented in the data table.
  • The screenshot below displays the row count value presented in the data table.
Power BI DAX counts all
Power BI DAX counts all

This is how we can count the row values using the Power Bi Dax Count all function in Power BI.

Check out, Power BI DAX Min Date Minus

Power BI DAX count based on condition

Let us see how to count the column value based on the condition by using a Power Bi function in Power Bi.

  • Load the data using the get data option on the power bi desktop. Click on the new measure from the ribbon and apply the below formula to count rows for the customer location called Maryland.
Based on condition = CALCULATE (
    DISTINCTCOUNT ( 'Sales_Table'[Product Name] ),
    FILTER ( 'Sales_Table', Sales_Table[Customer Location]="Marryland" )
)

Where,

  1. Based on condition = New Measure name
  2. DISTINCT COUNT = Function name
  3. Sales_Table = Table Name
  4. Product Name, Customer Location = Column Names
  • In the Power Bi report section, select the table visual and card visual. In the table visual select the Product Name, sales, and customer location fields from the field pane.
  • In the card visual drag and drop the created measure value to display the count value based on the condition applied.
  • The screenshot below displays the count value for the mentioned customer location name in the data table.
Power BI DAX count based on condition
Power BI DAX count based on condition

This is how we will filter the column based on condition by using the Power Bi.

Power BI DAX count distinct if

Let us see how we can count the distinct row values using the Power Bi Dax distinct Count function in Power BI.

In this example, we will count the distinct count value for the product name using the Power Bi distinct count function.

  • Load data into the Power Bi desktop, Select the new measure option from the ribbon under the Home tab and apply the below-mentioned formula.
Distinct if COUNT = CALCULATE(
    DISTINCTCOUNT( Sales_Table[Product Name] )
    ,Sales_Table[Product Name] = "laptop"
)

Where,

  1. Distinct if COUNT= New Measure name
  2. Sales_Table = Table Name
  3. DISTINCT COUNT = Function name
  4. Product Name = Column Name
  • Now in the report section, select the table visual and card visual. In the table visually drag and drop the Product Name, sales, and customer location fields from the field pane.
  • And in the card visual drag and drop the created measure value to display the distinct count values for the product name column presented in the data table.
  • The screenshot below displays the distinct count value presented in the data table for the mentioned column name.
Power BI DAX count distinct if
Power BI DAX count distinct if

This is how to count the distinct row values using the Power Bi Dax distinct Count function in Power BI.

Check out Power BI DAX Min Date Validation

Power BI DAX count contains

Here we will see how to count the number of rows if it contains a specific text using the Power Bi Count function.

  • Load the data using get data. Click on the New measure from the ribbon on Power bi desktop. Then write the below measure:
Countif = CALCULATE(COUNTROWS(Sales_Table),FILTER ( 'Sales_Table', Sales_Table[Customer Location]="Georgia"))

Where,

  1. Countif = New measure name
  2. Sales_Table = Table Name
  3. Customer Location = Column Name
  • In the Power Bi report section, select the table visual and card visual. In the table visual select the Product Name, sales, and customer location fields from the field pane.
  • In the card visual drag and drop the created measure value to display the sales value count for the mentioned location.
  • In the below screenshot, you can see that the card visually displays the sales count value.
Power BI DAX count contains
Power BI DAX count contains

This is how to count the number of rows if it contains a specific text using the Power Bi Count function.

Power BI DAX count duplicates

Let us see how to count the duplicate values presented in the data table for the selected column using the Power Bi count function.

In this example, we will find the duplicate values for the product name column from the data table.

  • Load the data using the get data option on the power bi desktop. Click on the new measure from the ribbon and apply the below formula to count rows
Duplicates = CALCULATE(COUNTA(Sales_Table[Product Name]),ALLEXCEPT(Sales_Table,Sales_Table[Product Name]))

Where,

  1. Duplicates = New measure name
  2. Sales_Table = Table Name
  3. Product Name = Column Name
  • In the Power Bi report section, select the table visually. In the table visual select the Product Name, sales, and the created measure value to display the duplicate values.
  • In the below screenshot, you can see that the card visually displays the duplicate value count.
Power BI DAX count duplicates
Power BI DAX count duplicates

This is how to count the duplicate values presented in the data table for the selected column using the Power Bi count function.

Check out, Power BI DAX Min Date

Power BI DAX count by date

Let us see how we can display the sales count value based on the date using the Power Bi count function in Power BI.

  • Load the data to the Power Bi desktop, Click on the New measure from the ribbon on Power bi desktop. Then write the below measure:
Count by date = COUNT(Sales_Table[Sales])

Where,

  1. Count by date = New measure name
  2. Sales_Table = Table Name
  3. Sales = Column Name
  • Now in the report section, select the slicer visual and card visual. In the slicer visually drag and drop the order date field and filter date value.
  • And in the card visual drag and drop the created measure value to display the sales count value for the selected date.
  • The screenshot below displays the sales count value for the selected date value.
Power BI DAX count by date
Power BI DAX count by date

This is how to display the sales count value based on the date using the Power Bi count function in Power BI.

Power BI DAX count by month

Let us see how we can display the sales count value based on the month using the Power Bi count function in Power BI.

  • Load the data to the Power Bi desktop, Click on the New measure from the ribbon on Power bi desktop. Then write the below measure:
Count by month = COUNT(Sales_Table[Sales])

Where,

  1. Count by month = New measure name
  2. Sales_Table = Table Name
  3. Sales = Column Name
  • Now in the report section, select the slicer visual and card visual. In the slicer visually drag and drop the order date field and filter month value.
  • And in the card visual drag and drop the created measure value to display the sales count value for the selected month.
  • The screenshot below displays the sales count value for the selected month called June.
Power BI DAX count by month
Power BI DAX count by month
  • In the same way, if we select any other month and the selected month has no sales then it displays the Blank value in the card visual as below:
Power BI DAX count by month example
Power BI DAX count by month example

This is how to display the sales count value based on the month using the Power Bi count function in Power BI.

Read: How to Add a Dropdown Slicer in Power BI

Power BI DAX count days

Let us see how we can display the sales count value based on the day using the Power Bi count function in Power BI.

  • Load the data to the Power Bi desktop, Click on the New measure from the ribbon on Power bi desktop. Then write the below measure:
Count by day = COUNT(Sales_Table[Sales])

Where,

  1. Count by date = New measure name
  2. Sales_Table = Table Name
  3. Sales = Column Name
  • Now in the report section, select the slicer visual and card visual. In the slicer visually drag and drop the order date field and filter day value. Day Value displays from 1 to 31.
  • And in the card visual drag and drop the created measure value to display the sales count value for the selected day value.
  • The screenshot below displays the sales count value for the selected day value.
Power BI DAX count days
Power BI DAX count days
  • In the same way, if we select any other day and the selected day has no sales then it displays the Blank value in the card visual as below:
Power BI DAX count days example
Power BI DAX count days example

This is how to display the sales count value based on the day using the Power Bi count function in Power BI.

This Power Bi Tutorial helps you to count the row values presented in the data table using the Power Bi Count function in Power Bi. Also covered below are highlighted headings:

  • Power BI DAX count
  • Power BI DAX counts distinct
  • Power BI DAX count slicer selection
  • Power BI DAX count group by
  • Power BI DAX count blank
  • Power BI DAX count and filter
  • Power BI DAX count boolean
  • Power BI DAX count greater than
  • Power BI DAX counts all
  • Power BI DAX count based on condition
  • Power BI DAX count distinct if
  • Power BI DAX count contains
  • Power BI DAX count duplicates
  • Power BI DAX count by date
  • Power BI DAX count by month
  • Power BI DAX count days

You may also like the below Power BI tutorials:

>