Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Monthly Totals For Previous Quarter

Status
Not open for further replies.

supportsvc

Technical User
Jan 24, 2018
249
US
Hello,
I can't seem to figure out how to get
First month of the previous quarter total
Second and Third

I have the following but the totals aren't correct UNLESS it's ran in the 1st month of the current quarter for the previous quarter data.

here are the snippets
Code:
Sum(IIf(Month([CheckDate])=Month(Date())-3,[WagesSubjToEmployerUI],0)) AS Mth1, Sum(IIf(Month([CheckDate])=Month(Date())-2,[WagesSubjToEmployerUI],0)) AS Mth2, Sum(IIf(Month([CheckDate])=Month(Date())-1,[WagesSubjToEmployerUI],0)) AS Mth3

Code:
HAVING (((Year([CheckDate]))=[Forms]![frmProcessing]![CurrentYear]) AND ((DatePart("q",[CheckDate]))=DatePart("q",Date())-1)

How/what can be changed so Mth1 is actually the First month of the previous quarter, etc ...?

Since we're in May and still running Quarter 1 data, the Mth1, Mth2, Mth3 are incorrect now. They were correct when ran last month in April.
 
I think I found a solution

Code:
Sum(IIf(((Month([CheckDate])-1) Mod 3)+1=1,[WagesSubjToEmployerUI],0)) AS Mth1, Sum(IIf(((Month([CheckDate])-1) Mod 3)+1=2,[WagesSubjToEmployerUI],0)) AS Mth2, Sum(IIf(((Month([CheckDate])-1) Mod 3)+1=3,[WagesSubjToEmployerUI],0)) AS Mth3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top