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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Nested If with Multiple And conditions

HI,

 

So im trying to get a Calculated column which returns  Overdue or Not overdue based on certain criteria

First time poster so please forgive any errors in required  format 

 

Below is what i came up with

Overdue_VW =
IF(And([Status]="Completed",[CompleteBy]<[CompletedDate]),"Overdue",
if(and([Status]<>"Completed",And([CompletedDate]="",And([CompleteBy]<=DATE(YEAR(TODAY()),MONTH(TODAY()),1),And([Status]<>"Deleted")))),"Overdue","Not Overdue"))

 

I also tried  ( although im not familiar with the switch expression, first time ive tried to use it)

 

Overdue_VW =
IF(And([Status]="Completed",[CompleteBy]<[CompletedDate]),"Overdue",
Switch(
[Status]<>"Completed",
[CompletedDate]="",
[CompleteBy]<=DATE(YEAR(TODAY()),MONTH(TODAY()),1),
[Status]<>"Deleted"),
"Overdue", "Not Overdue"))
 
I think im close, but cant quite work out why either option isnt working,  Any help on this would be greatly appreciated
1 ACCEPTED SOLUTION

@Anonymous change you expression like this, i just copied your expression assuming tht is the business logic you want.

 

Overdue_VW = 
IF([Status]="Completed" && [CompleteBy]<[CompletedDate],"Overdue",
IF(
[Status]<>"Completed" &&
[CompletedDate]=BLANK() &&
[CompleteBy]<=DATE(YEAR(TODAY()),MONTH(TODAY()),1) &&
[Status]<>"Deleted",
"Overdue", "Not Overdue"))

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
ryan_mayu
Super User
Super User

@Anonymous 

when you have serveral conditions of AND logic, please use && instead of AND

e.g and(condition1,and(condition2,condition3))

you can try condition1 && condition2 && condition3

That will be easier.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Anonymous change you expression like this, i just copied your expression assuming tht is the business logic you want.

 

Overdue_VW = 
IF([Status]="Completed" && [CompleteBy]<[CompletedDate],"Overdue",
IF(
[Status]<>"Completed" &&
[CompletedDate]=BLANK() &&
[CompleteBy]<=DATE(YEAR(TODAY()),MONTH(TODAY()),1) &&
[Status]<>"Deleted",
"Overdue", "Not Overdue"))

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thank you, this drove me nuts all day

 

i can see i was mixing an AND  with &&  which was over complicating things

 

really appreciate your time and the time of everyone who answered 

Fowmy
Super User
Super User

@Anonymous 

Could you explain in words what how do you need to calculate the OverDue and NonOverDue? 

If you are satisfied with my answer, please mark it as a solution so others can easily find it.

Don't forget to give KUDOS ? to replies that help answer your questions


Subscribe to ExcelFort: Learn Power BI, Power Query and Excel

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Anonymous post a sample data and business logic to calculate this new column.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi

 

Sorry took me a while to work out how to get a sample set of data on here, Not totally sure this will work either 

 

Test PBI file 

 

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.