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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
knowledgesearch
Frequent Visitor

Multiple conditions with IF (calculated, conditional column)

I have a baseline date measure for project tasks and todays measure, I want an if statement that states if the date is greater than or equal to 30 days then the RAG status is green, if the date is less than 30 then it is amber, if it less than 10 days then it is red. 

 

The measure i can is =if [Baseline Date]-[Today's Date]>=30 , ="Green", or if [Baseline Date]-[Today's Date]<=30, = "Amber" or if [Baseline Date]-[Today's Date]<=30 , ="Red")))

 

Am I doing something wrong, I have searched numerous forums and pages but all are coming up with either nested IF statements that do not work or other measures that don't quite fit my condition. 

5 REPLIES 5
parry2k
Super User
Super User

@knowledgesearch Not sure what else I can say based on the information you provided. Maybe share a sample pbix file using one drive/google drive and remove the sensitive information before sharing.



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.

parry2k
Super User
Super User

@knowledgesearch there was a typo, it is fixed now.



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.

It still says there is an error the syntax for return is incorrect

parry2k
Super User
Super User

@knowledgesearch It is much easier with switch, although you can also do with IF but SWITCH is easy to read and debug.

 

 

VAR __Days = [Baseline Date]-[Today's Date]
RETURN
SWITCH ( TRUE (),
   __Days >= 30, "Green",
   __Days >= 10, "Amber",
   "Red"
)

 

 



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.

It is saying incorrect syntax for return, this is a calculated column measure I have a calculated column that calculates the difference between the baseline and today's date. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.