Power Query M code
let
Source = YourTable,
AddedStatus = Table.AddColumn(
Source,
"HasDiscount",
each if [DiscountPercent] = null then false else [DiscountPercent] > 0,
type logical
)
in
AddedStatus
Explicitly tests for null before comparing, since comparing a value to null directly can behave unexpectedly in M.
let
Source = YourTable,
AddedStatus = Table.AddColumn(
Source,
"HasDiscount",
each if [DiscountPercent] = null then false else [DiscountPercent] > 0,
type logical
)
in
AddedStatus
Checking = null explicitly, rather than assuming a missing value acts as 0 or false, avoids surprises when the column mixes real values and nulls.
Browse all 145 snippets in the Power Query M Code Snippets, or search the library for something similar to Check for Null Safely Inside a Condition.