Power BI Count If True

In this Power bi article, we will discuss What Power Bi Count if is and how to work with Power Bi Count if true with examples in Power bi. And also, we will discuss the below points:

  • Power bi count if true and false
  • Power bi count rows if true

Power BI count if

  • The Count if is a function used in Excel to count the values in the range based on the condition. In Power Bi, the Count if Function is not available.
  • So, in Power bi, we can apply the same logic of the Count if function by using the CountAX function and CountRows function

Power Bi Syntax of CountAX function is :

COUNTAX(<table>,<expression>)

Power Bi Syntax of CountRows function is :

COUNTROWS([<table>])

Power bi count if true

Here we will discuss the Power bi count if true with an example. You can download the sample data table from here.

In this example, we will find the count of true values using the Power BI COUNTAX function in the Power Bi report.

  • Open the Power bi desktop and then Load the data using the get data option, Click on the new measure from the ribbon in the power bi desktop.
  • Then apply the below measure formula to count the true values:
Countif = COUNTAX(FILTER('Stock Sheet',[True/False]=TRUE()),TRUE())

Where,

  1. Countif = Measure name
  2. COUNTAX = Function name
  3. Stock Sheet = Table name
  4. True/False = Column name
  • Now to see the output, select the table visual from the visualization pane. drag and drop the stock name and true/false field from the field pane.
  • In the same way, select the card visual and drag-drop the created measure value. In the below screenshot, you can see that the card visually displays the number of true value counts.
Power bi count if true
Power bi count if true

This is how to work with the  Power bi count if true in Power BI.

Power bi Count of True and False

Let us see how to work with the Power BI count of true and false count values using the Power Bi DAX Count function in Power BI.

In this example, we will create two measure values to find the total number of true values and false values presented in the table.

  • Load the table data into the Power BI desktop using the get data option, once the data has been loaded. Click on the new measure under the modeling tab.
  • In the measure formula bar, apply the below formula to check the true value count and click on the check icon.
True_Measure = COUNTAX(FILTER('Stock Sheet', 'Stock Sheet'[True/False]=TRUE()), 'Stock Sheet'[True/False])

where,

  1. True_Measure = Measure name
  2. COUNTAX = Function name
  3. Stock Sheet = Table name
  4. True/False = Column name

In the same way, select another new measure and apply the below formula to check the false value count and click on the check icon.

False_Measure = COUNTAX(FILTER('Stock Sheet', 'Stock Sheet'[True/False]=FALSE()), 'Stock Sheet'[True/False])

where,

  1. False_Measure= Measure name
  2. COUNTAX = Function name
  3. Stock Sheet = Table name
  4. True/False = Column name
  • Now to see the output, select the table visual from the visualization pane. drag and drop the stock name and true/false field from the field pane. And also the created measure values into it.
  • In the below screenshot, you can see that the True_measure returns the number of true value counts and the False_measure returns the number of false value counts presented in the existing column.
Power bi Count of True and False
Power bi Count of True and False

This is how to work with the Power BI count of true and false count values using the Power Bi DAX Count function in Power BI.

Power Bi Count Rows if True

Here we will see how to count rows if true using the count rows function in Power BI.

In this example, we will find the count of true values using the Power BI COUNT ROWS function in the Power Bi report.

  • Log in to the Power bi desktop and then Load the data using the get data option, Click on the new measure from the ribbon in the power bi desktop.
  • Then apply the below measure formula to count the true values using the count row function:
Count of True = COUNTROWS(FILTER('Stock Sheet','Stock Sheet'[True/False] = TRUE()))

Where,

  1. Count of True = Measure name
  2. COUNTAX = Function name
  3. Stock Sheet = Table name
  4. True/False = Column name
  • Now select the table visual from the visualization pane. drag and drop the stock name and true/false field from the field pane.
  • In the same way, select the card visual and drag-drop the created measure value. In the below screenshot, you can see that the card visually displays the number of true value counts.
Power Bi Count Rows if True
Power Bi Count Rows if True

This is how to count rows if true using the count rows function in Power BI.

In this Power bi article, we have discussed What Power Bi Count if is and how to work with Power Bi Count if true with examples in Power bi. And also, covered the below points:

  • Power bi count of true and false
  • Power bi count rows if true

You may also liek the following power bi tutorials:

>