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:
- 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
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.
- 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,
- Product Count = New Measure name
- COUNT = Function name
- Sales_Table = Table Name
- 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.
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,
- Product Count = New Measure name
- DISTINCT COUNT = Function name
- Sales_Table = Table Name
- 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.
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,
- Count based on slicer selection = New Measure name
- COUNT = Function name
- Sales_Table = Table Name
- 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.
- 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.
In the same way, if we select different products from the slicer visual, the card visual displays the selected product count value.
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,
- Group by = New Measure name
- COUNT = Function name
- Sales_Table = Table Name
- Product Name = Column Name
Now in the data table, filter the mentioned customer location column as below to check the product count manually:
- 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.
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,
- Blank Values Count = New Measure name
- COUNTBLANK = Function name
- Sales_Table = Table Name
- Discount = Column Name
Now in the data table filter the mentioned discount column below to check the count manually:
- 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.
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,
- Count with Filter = New Measure name
- COUNTROWS = Function name
- Sales_Table = Table Name
- 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.
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,
- Boolean = New column name
- Sales_Table = Table Name
- Discount = Column Name
- 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.
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,
- Sales Count = New measure name
- Sales_Table = Table Name
- 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.
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,
- Count ALL = New Measure name
- Count rows = Function name
- Sales_Table = Table Name
- 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.
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,
- Based on condition = New Measure name
- DISTINCT COUNT = Function name
- Sales_Table = Table Name
- 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.
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,
- Distinct if COUNT= New Measure name
- Sales_Table = Table Name
- DISTINCT COUNT = Function name
- 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.
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,
- Countif = New measure name
- Sales_Table = Table Name
- 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.
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,
- Duplicates = New measure name
- Sales_Table = Table Name
- 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.
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,
- Count by date = New measure name
- Sales_Table = Table Name
- 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.
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,
- Count by month = New measure name
- Sales_Table = Table Name
- 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.
- 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:
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,
- Count by date = New measure name
- Sales_Table = Table Name
- 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.
- 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:
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:
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com