Forum Discussion
Boolean field shows different value on web from desktop
- 3 years ago
but my field created in M, I modified it this way
= Table.AddColumn(ProximoDia, "mesatual", each if Date.IsInCurrentMonth([DataBase]) then 1 else 0)
The difference in the boolean field representation between Power BI Desktop and the Power BI web service is due to how the two platforms handle boolean values. In Power BI Desktop, boolean values are represented as "True" and "False," while in the Power BI web service, they are represented as numeric values of 1 and 0 (or -1 in some cases).
To ensure consistency in the representation of boolean fields across both Power BI Desktop and the web service, you can use the DAX function `IF` to explicitly convert the boolean expression to numeric values.
Here's an example of how you can use the `IF` function to convert a boolean field to numeric values in Power BI Desktop:
```dax
NumericField = IF('Table'[BooleanField], 1, 0)
```
In this example, `'Table'[BooleanField]` represents your boolean field. If the boolean field is true, the `IF` function will return 1; otherwise, it will return 0.
By using this formula to create a new calculated column or measure in Power BI Desktop, you can ensure that the boolean field is represented consistently as numeric values of 1 and 0 across both Power BI Desktop and the Power BI web service.
Please note that when you create a boolean field directly in the Power BI web service using functions like `current year` and `current month`, the representation of true and false as 0 and -1 is the default behavior. Using the `IF` function as described above can help maintain consistency with Power BI Desktop.
- sandromarani3 years agoNew Member
but my field created in M, I modified it this way
= Table.AddColumn(ProximoDia, "mesatual", each if Date.IsInCurrentMonth([DataBase]) then 1 else 0)