Forum Discussion
Rich_Wyeth
1 year agoHelper I
Handle Null in IF Statement
Hi, I have the following column witha multiple if: = Table.AddColumn(#"Due Days", "Due Category", each if [Due Days] >= 0 then "Overdue" else if [Due Days] <= -365 then "Over 12 Months" else ...
- 1 year ago
Hi Rich_Wyeth
Use the below M Code:
= Table.AddColumn(#"Due Days", "Due Category", each if [Due Days] = null then null else if [Due Days] >= 0 then "Overdue" else if [Due Days] <= -365 then "Over 12 Months" else if [Due Days] < -180 then "6-12 Months" else if [Due Days] < -90 then "3-6 Months" else if [Due Days] < -30 then "1-3 Months" else "1 Month" ) - 1 year ago
hi Rich_Wyeth ,
try like:
= Table.AddColumn(
#"Due Days",
"Due Category",
each
if [Due Days] >= 0 then "Overdue"
else if [Due Days] <= -365 then "Over 12 Months"
else if [Due Days] < -180 then "6-12 Months"
else if [Due Days] < -90 then "3-6 Months"
else if [Due Days] < -30 then "1-3 Months"
else if [Due Days] =null then null
else "1 Month"
)
Angith_Nair
1 year agoContinued Contributor
Hi Rich_Wyeth
Use the below M Code:
= Table.AddColumn(#"Due Days", "Due Category", each
if [Due Days] = null then null
else if [Due Days] >= 0 then "Overdue"
else if [Due Days] <= -365 then "Over 12 Months"
else if [Due Days] < -180 then "6-12 Months"
else if [Due Days] < -90 then "3-6 Months"
else if [Due Days] < -30 then "1-3 Months"
else "1 Month"
)Rich_Wyeth
1 year agoHelper I
Thank you, works a treat! I was so transfixed on an if, I hadn't thought of that! Thank you!