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

Using YTD field in If statement

I am trying to write an if statement in an expression using a YTD (Year to Date) field.

What I want to do is find out if the month "July" falls within the YTD field.

So something like.....If YTD contains July, then 1, else 0.  I just don't know how to make the connection on a value that isn't actually part of the yield biut is associated with it.

Thanks in advance,

Steve

15 Replies
sunny_talwar

What values does your YTD field contains??

Not applicable

Are you asking to shift the YTD flag calculation from Jan to July Month ? or

If you already have [YTDField] in your table & we want check the YTDField in July month or not, then you can generaly IF statement like below:

IF( Month(YTDField)=7,1,0) AS YTDFlag

zagzebski
Creator
Creator
Author

My YTD values are "YTD" and "NOYTD"

zagzebski
Creator
Creator
Author

I have already identifed in the script which months are "YTD" and which months are "NOYTD". My issue is that I have an expression that I need to by able to identify specfic months in an if statement.

So I need to be able to write something along the lines of...

If YTD contains "July", then Expression 1, else expression 2

zagzebski
Creator
Creator
Author

My YTD values are "YTD" and "NOYTD"

sunny_talwar

Can't you do this?

If(Num(Month(Today())) >= 7, Expression1, Expression2)

Where Month(Today()) will give your YTD information and 7 is used for month July

zagzebski
Creator
Creator
Author

No because YTD is always changing. When next year comes July won't be associated with the YTD field until July comes. It needs to be dynamic.

I have 12 columns one for each month and each one needs to have this logic. THanks.

Anonymous
Not applicable

Hi Zagzebski,

IF( Num(Month(YTD))= 7,1,0) AS YTDFlag

or

IF( Month(YTD)= 'JUL',1,0) AS YTDFlag

Regards

Neetha

sunny_talwar

Why did you choose July right now? Is it the max date in your database? What was the logic?