Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 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")
I need to incase an statement that says if [Due Days] = null then Due Category will read null, as at present it is returning error. I have tried to do this, but I can't seem to get it right.
How to do create the check whilst adding the column?
Thanks in Advance
Solved! Go to Solution.
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"
)
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"
)
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"
)
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"
)
Thank you, works a treat! I was so transfixed on an if, I hadn't thought of that! Thank you!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 39 | |
| 37 | |
| 29 | |
| 24 |
| User | Count |
|---|---|
| 124 | |
| 107 | |
| 80 | |
| 69 | |
| 67 |