Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
spandy34
Responsive Resident
Responsive Resident

Conditional Column date and multiple criteria

Hi

 

I would like to create a Conditional Column called Status in Power Query and wondered if someone could help with the code for the following please as I am unsure of how to do it:

spandy34_1-1716931367236.png

 

 

 

If the Due Date is less than Today and the [Milestone/Description] field is Blank or “Not Started” then input “Red”

Or

If the Due Date is within 4 weeks and the [Milestone/Description] field is Blank or “Not Started” then input “Amber”

Or

If the Due Date is greater than Today and the [Milestone/Description] field is Blank or “Not Started” or “In Progress” or “Complete” then input “Green”

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @spandy34 

I am confused that

1.the 4 weeks means due date>today and due date < future 4 weeks or due date>pre 4 weeks and due date < today?

2.Based on the first question, if the 4 weeks means ddue date>pre 4 weeks and due date < today, then should the firse condition be Due Date<pre 4 weeks instead of today?

Based on my understanding, i create the following conditions:

a. Due date<pre 4 weeks

b.due date>=pre 4 weeks and due date < today

c.dure date>=today

 

let 
_today=DateTime.Date(DateTime.LocalNow()),
_4weeks=Date.AddWeeks(_today,-4),
_condition=
if [Due Date]<_4weeks and ([#"Milestone/Description"]="" or [#"Milestone/Description"]="Not Started") then "Red" else if [Due Date]<_today  and [Due Date]>=_4weeks and ([#"Milestone/Description"]="" or [#"Milestone/Description"]="Not Started") then "Amber"  else if  [Due Date] >=_today and ([#"Milestone/Description"]="" or [#"Milestone/Description"]="Not Started" or [#"Milestone/Description"]="In Progress" or [#"Milestone/Description"]="Complete") then "Green" else null
in _condition

 

Output

vxinruzhumsft_1-1716948393227.png

And you can also refer to the attachment.

 

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @spandy34 

I am confused that

1.the 4 weeks means due date>today and due date < future 4 weeks or due date>pre 4 weeks and due date < today?

2.Based on the first question, if the 4 weeks means ddue date>pre 4 weeks and due date < today, then should the firse condition be Due Date<pre 4 weeks instead of today?

Based on my understanding, i create the following conditions:

a. Due date<pre 4 weeks

b.due date>=pre 4 weeks and due date < today

c.dure date>=today

 

let 
_today=DateTime.Date(DateTime.LocalNow()),
_4weeks=Date.AddWeeks(_today,-4),
_condition=
if [Due Date]<_4weeks and ([#"Milestone/Description"]="" or [#"Milestone/Description"]="Not Started") then "Red" else if [Due Date]<_today  and [Due Date]>=_4weeks and ([#"Milestone/Description"]="" or [#"Milestone/Description"]="Not Started") then "Amber"  else if  [Due Date] >=_today and ([#"Milestone/Description"]="" or [#"Milestone/Description"]="Not Started" or [#"Milestone/Description"]="In Progress" or [#"Milestone/Description"]="Complete") then "Green" else null
in _condition

 

Output

vxinruzhumsft_1-1716948393227.png

And you can also refer to the attachment.

 

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi

 

Thank you - the principal worked and I have now got the column created with this solution  Thank you for your help

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors