Power BI Exchange

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.
 View Only
  • 1.  How to count boolean ( 0 | 1 )

    Gold Contributor
    Posted Apr 12, 2019 03:57 AM
    ​I have a column (Column_Name) in a table (Table_Name) that contains boolean (0 | 1) values. How to count for each value ???

    ------------------------------
    Khurram Muhammad
    Data Analyst
    Karachi
    ------------------------------


  • 2.  RE: How to count boolean ( 0 | 1 )

    Bronze Contributor
    Posted Apr 12, 2019 07:40 AM
    You can do this using a "Measure". You can create a measure by right clicking on your table.

    New Measure
    Next you can count the number of 1's using the following statement:

    If your column is of type "Text"
    NumberOfOnes = COUNTAX(FILTER(Table_Name,[Column_Name]="1"),Table_Name[Column_Name])

    If your column is of type "Boolean"
    NumberOfOnes = COUNTAX(FILTER(Table_Name,[Column_Name]=TRUE()),TRUE())

    ------------------------------
    Robert Sep
    Chief Qoder
    ------------------------------



  • 3.  RE: How to count boolean ( 0 | 1 )

    Gold Contributor
    Posted Apr 12, 2019 08:11 AM
    Thanks a lot Robert.

    What about, If column type is "Whole Number" ??


    ------------------------------
    Khurram Muhammad
    Data Analyst
    Karachi
    ------------------------------



  • 4.  RE: How to count boolean ( 0 | 1 )

    Bronze Contributor
    Posted Apr 12, 2019 09:22 AM
    For number:
    NumberOfOnes = COUNTAX(FILTER(Table_Name;[Column_Name]=1);1)

    ------------------------------
    Robert Sep
    Chief Qoder
    ------------------------------



  • 5.  RE: How to count boolean ( 0 | 1 )

    Gold Contributor
    Posted Apr 14, 2019 02:13 AM
    Thanks a lot Robert. You'r genius.

    ------------------------------
    Khurram Muhammad
    Data Analyst
    Karachi
    ------------------------------



  • 6.  RE: How to count boolean ( 0 | 1 )

    Posted 17 days ago
    Robert,

    I used the measure you provided to count True/False values, however, I am finding that the formula seems to be tacking on an extra 1 to my counts.  For example, if I have 20 TRUE results in a column, the measure represents it as 21.  I'm not certain where this extra integer is coming from.  I can of course insert a column that deducts 1 from the results, but I dislike doing this because in this particular dashboard I have 3 columns that each have their own measure to count the true/false items.  Any advice on how to deal with this extra number?  I can at least confirm that it is +1 across the board for every category, but I cannot seem to determine what Power BI sees as that extra +1.  Thoughts?

    ------------------------------
    Keisha Gamman
    Data Analyst
    ------------------------------