Jump to content

Column calculated with subtraction of two dates


Go to solution Solved by Tyler Kendle,

Recommended Posts

Hi all,

 

I Generate a calculated column that subtracts the dates. Now I need, depending on the result of this calculated column, to generate another column with the condition: if the result is less than -5, it returns “Time” and if it is greater, it returns “Late”.

I try the following but it gives me an error, how could I achieve it?
 

WHEN [name calculated column] <-5 THEN “Tiempo”

IMG_5695.jpeg

IMG_5696.jpeg

Link to comment
Share on other sites

Just double checking here, are you using a Case Statement for that When clause?  I typically organize my case statements vertically just to make things easier to read.  So something like this:

Case
When [Dias Prep] IS NULL Then Null
When [Dias Prep]<-5 THEN “Tiempo”
Else "Late"
End

Wondering if your issue is just the Case and End prompts missing... Or perhaps it's because it's a TimeSpan variable, could you change that column to an Integer?

Link to comment
Share on other sites

  • Solution

How did you generate the column that subtracted the dates?  Did you use "DateDiff"?  That should return a "real" value which should work fine instead of an Integer.

Here is an example:

I have two columns Today's date, and Date Created.
Step 1:  Calculate Days between the two columns using DateDiff
Formula: DateDiff('day',[Date Created],[Today])

Step 2: Create your new column with your case statement.
Formula: 
Case  
When [Days Open]<5 Then "Tiempo"
Else "Late"
End

Those are just examples, I know your #s are slightly different but the concept should still work for you.

image.png.8723be37cd8d88ac6c63b48cfc3cf050.png

image.png.992e9d032d90b37b1f943705dd86bcea.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...