Forum Discussion

sasdfasdfsad's avatar
sasdfasdfsad
Advocate IV
1 year ago
Solved

Best Practice: Binary True/False vs Integer 1/0 ?

I want to use a flag field for if records have a given status, or are marked for deletion, etc... I was using an Integer with a 0 for FALSE and 1 for TRUE.   Then I did a nice SUM on the field ...
  • bhanu_gautam's avatar
    1 year ago

    sasdfasdfsad Readability: True/False fields are more intuitive and user-friendly, especially when used in slicers or filters. Users can easily understand the meaning of True/False compared to 0/1.
    Data Modeling: True/False fields are explicitly designed for boolean logic, which can make your data model more semantically correct and easier to understand.
    DAX Functions: Power BI's DAX language has built-in support for boolean fields, which can simplify your calculations and improve readability.

     

    CountOfTrueValues = COUNTROWS(FILTER(Table, Table[FlagField] = TRUE()))

  • parry2k's avatar
    1 year ago

    sasdfasdfsad I don't see any different storing 0/1 or True/False, only thing come in mind is that you cannot use True/False value in the filter page (like visual/page/report level filters) other than that I don't see any difference.

     

    Other difference you already point out that you will use count with condition, if you want count of true or false values, although sum is always returning sum of true values.