A
C
- CALCULATE
- CALCULATETABLE
- CALENDAR
- CALENDARAUTO
- CEILING
- CHISQ.DIST
- CHISQ.DIST.RT
- CHISQ.INV
- CHISQ.INV.RT
- CLOSINGBALANCEMONTH
- CLOSINGBALANCEQUARTER
- CLOSINGBALANCEYEAR
- COALESCE
- COLUMNSTATISTICS
- COMBIN
- COMBINA
- COMBINEVALUES
- CONCATENATE
- CONCATENATEX
- CONFIDENCE.NORM
- CONFIDENCE.T
- CONTAINS
- CONTAINSROW
- CONTAINSSTRING
- CONTAINSSTRINGEXACT
- CONVERT
- COS
- COSH
- COT
- COTH
- COUNT
- COUNTA
- COUNTAX
- COUNTBLANK
- COUNTROWS
- COUNTX
- COUPDAYBS
- COUPDAYS
- COUPDAYSNC
- COUPNCD
- COUPNUM
- COUPPCD
- CROSSFILTER
- CROSSJOIN
- CUMIPMT
- CUMPRINC
- CURRENCY
- CURRENTGROUP
- CUSTOMDATA
D
E
I
N
O
P
R
S
- SAMEPERIODLASTYEAR
- SAMPLE
- SEARCH
- SECOND
- SELECTCOLUMNS
- SELECTEDMEASURE
- SELECTEDMEASUREFORMATSTRING
- SELECTEDMEASURENAME
- SELECTEDVALUE
- SIGN
- SIN
- SINH
- SLN
- SQRT
- SQRTPI
- STARTOFMONTH
- STARTOFQUARTER
- STARTOFYEAR
- STDEVX.P
- STDEVX.S
- STDEV.P
- STDEV.S
- SUBSTITUTE
- SUBSTITUTEWITHINDEX
- SUM
- SUMMARIZE
- SUMMARIZECOLUMNS
- SUMX
- SWITCH
- SYD
T
U
In this article, we will discuss how to use the Power BI DAX function COUNTROWS in detail, including its syntax and examples of its usage.
Syntax of the COUNTROWS Function
The syntax of the COUNTROWS function is straightforward. It takes a table or an expression that returns a table as its argument and returns the number of rows in the table. The general syntax for the COUNTROWS function is as follows:
COUNTROWS(❰table❱)
The following example demonstrates how to use the COUNTROWS function to count the number of rows in a table named 'Sales':
CountRowsSales = COUNTROWS(Sales)
Examples of Using the COUNTROWS Function
Example 1: Counting the Total Number of Records in a Table
One of the most common use cases of the COUNTROWS function is to count the total number of records in a table. To do so, you simply need to pass the name of the table as an argument to the COUNTROWS function.
The following example demonstrates how to use the COUNTROWS function to count the total number of records in a table named 'Sales':
CountAllSales = COUNTROWS(Sales)
Example 2: Counting the Number of Records That Meet Specific Criteria
Another common use case of the COUNTROWS function is to count the number of records that meet specific criteria. To do so, you need to create a filter context using the FILTER function and then pass the filtered table as an argument to the COUNTROWS function.
The following example demonstrates how to use the COUNTROWS function to count the number of sales made by a specific salesperson:
CountSalesBySalesperson =
COUNTROWS(
FILTER(
Sales,
Sales[Salesperson] = “John Smith”
)
)
Example 3: Calculating the Percentage of Records That Meet Certain Conditions
The COUNTROWS function can also be used to calculate the percentage of records that meet certain conditions. To do so, you need to use the DIVIDE function to divide the number of rows that meet the criteria by the total number of rows in the table.
The following example demonstrates how to use the COUNTROWS function to calculate the percentage of sales made by a specific salesperson:
SalesPercentageBySalesperson =
DIVIDE(
COUNTROWS(
FILTER(
Sales,
Sales[Salesperson] = “John Smith”
)
),
COUNTROWS(Sales)
)
The Power BI DAX function COUNTROWS is a versatile tool that can be used to count the number of rows in a table or a filtered table. In this article, we discussed its syntax and provided examples of its usage in various scenarios. By mastering the COUNTROWS function, you can gain a deeper understanding of your data in Power BI and make more informed business decisions.