Joined: 03 Jun 2014
Location: United States
Online Status: Offline
Posts: 41
Topic: If AND then Else? Posted: 02 Jan 2019 at 8:53am
Hello,
I can't seem to get this right.
If {PR_EmployeeTaxHistory.CalendarMonth} = "01" and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()) then ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1 else
ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())
What is the proper syntax?
I'm trying to have it return last year's data IF it's the current month (January) and current year only.
This is to run 4th quarter data after the end of the year.
So today is a new year and needs to be still producing last year's data then in Feb it'll show the current year's data, etc ....
I added ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1 to run the reports for 4th quarter last year but want to set it so no one has to go into and edit it each year
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 03 Jan 2019 at 7:30am
(MONTH(today)=1 and
ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(today-1))
OR
(MONTH(today)>1 and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(today))
Joined: 03 Jun 2014
Location: United States
Online Status: Offline
Posts: 41
Posted: 03 Jan 2019 at 10:37am
Tried this as well
If
(Month(CurrentDate)= 1 and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()))
then
(ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1
and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group})
else
(ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())
and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group})
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 04 Jan 2019 at 4:05am
in a select you do not need the if-then
(
(MONTH(today)=1 and
ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(today-1))
OR
(MONTH(today)>1 and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(today))
)
and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group})
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 07 Jan 2019 at 2:23am
Sorry, move the "-1" in the first part to outside the first parenth.
It was giving you the year from yesterday ("year(today-1)") but you want the year from today -1 ("year(today)-1".
(
(MONTH(today)=1 and
ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(today)-1)
OR
(MONTH(today)>1 and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(today))
)
and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group})
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum