Author |
Message |
Stircrazy08
Newbie
Joined: 12 Nov 2014
Location: United States
Online Status: Offline
Posts: 34
|
Topic: SQL question Posted: 11 Dec 2014 at 12:39pm |
I have a report that i am writing. and i use a select for from and to dates on the invoicedate, and i also have a item select(between) which works.
for the date select the user inputs say 11/1/2014-11/30/2014.
and the report gives the qty/dollar sold for that range.
is there a way to create a column that will display the same data qty/dollar for 11/1/2013 - 11/30/2013.
if you create a SQL field will that go off the db table to pull the data no matter what date selection you do on the initial report select?
|
Peter F
|
IP Logged |
|
z9962
Senior Member
Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
|
Posted: 15 Dec 2014 at 3:17am |
are you displaying your report details section? or just at a group level?
|
IP Logged |
|
Stircrazy08
Newbie
Joined: 12 Nov 2014
Location: United States
Online Status: Offline
Posts: 34
|
Posted: 16 Dec 2014 at 10:09am |
right now, i am only displaying group footer.
i am surpressing/no drill down on detail.
|
Peter F
|
IP Logged |
|
z9962
Senior Member
Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
|
Posted: 16 Dec 2014 at 11:52pm |
Do you have 1 parameter as a date range? or two parameters from and to?
If one as a range you could try in your select criteria
(invoicedate in {?dateRange} or invoicedate in DATEADD("yyyy",-1,minimum({?dateRange})) and DATEADD("yyyy",-1,maximum({?dateRange})))
this will then return records for current and previous year. you can then use a formula to show the correct data at the group level.
|
IP Logged |
|
Stircrazy08
Newbie
Joined: 12 Nov 2014
Location: United States
Online Status: Offline
Posts: 34
|
Posted: 17 Dec 2014 at 10:31am |
I have two parameters that i created. fromdate; todate.
very new to this, does this go in the SQL expression Fields or in the select expert under invoicedate??
Thanks for helping!!
|
Peter F
|
IP Logged |
|
Stircrazy08
Newbie
Joined: 12 Nov 2014
Location: United States
Online Status: Offline
Posts: 34
|
Posted: 17 Dec 2014 at 10:46am |
this is what i put in the select expert.
tells me you cant summarize the field:
?prompt from date
{AR_InvoiceHistoryDetail.ItemCode} in {?FROM ITEM} to {?TO ITEM} and
({AR_InvoiceHistoryHeader.InvoiceDate} in {?PROMPT FROM DATE} to {?PROMPT TO DATE} or
{AR_InvoiceHistoryHeader.InvoiceDate} in DATEADD("yyyy",-1,minimum({?PROMPT FROM DATE})) and
DATEADD("yyyy",-1,maximum({?PROMPT TO DATE})))
|
Peter F
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 18 Dec 2014 at 4:52am |
You cannot use maximum in the select expert. You might be able use it in a group select (never tried before though). The only option I can think of is a command or a stored procedure.
|
IP Logged |
|
z9962
Senior Member
Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
|
Posted: 18 Dec 2014 at 9:37pm |
you can use the min / max if the parameter was a range. Though as you are using two parameters your select expert will look like
{AR_InvoiceHistoryDetail.ItemCode} in {?FROM ITEM} to {?TO ITEM} and
({AR_InvoiceHistoryHeader.InvoiceDate} in {?PROMPT FROM DATE} to {?PROMPT TO DATE} or {AR_InvoiceHistoryHeader.InvoiceDate} in DATEADD("yyyy",-1,{?PROMPT FROM DATE}) to DATEADD("yyyy",-1,{?PROMPT TO DATE}))
|
IP Logged |
|
Stircrazy08
Newbie
Joined: 12 Nov 2014
Location: United States
Online Status: Offline
Posts: 34
|
Posted: 19 Dec 2014 at 3:34am |
Z9962,
i changed my fields and made it a date range like your previous post, first time using that. thanks.
so, my select is.
{AR_InvoiceHistoryDetail.ItemCode} in {?FROM ITEM} to {?TO ITEM} and
({AR_InvoiceHistoryHeader.InvoiceDate} in {?daterange} or
{AR_InvoiceHistoryHeader.InvoiceDate} in DATEADD("yyyy",-1,minimum({?DateRange})) and
DATEADD("yyyy",-1,maximum({?daterange})))
when i check the syntax, i get the error:
A Date-Time range is required here, and it highlights the following part of the statement.
DATEADD("yyyy",-1,minimum({?DateRange}))
my daterange parameter was created with type:DATE (Static)
Peter
|
Peter F
|
IP Logged |
|
z9962
Senior Member
Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
|
Posted: 19 Dec 2014 at 3:51am |
double check what i wrote...
in last example i did not use DateRange
{AR_InvoiceHistoryDetail.ItemCode} in {?FROM ITEM} to {?TO ITEM} and
({AR_InvoiceHistoryHeader.InvoiceDate} in {?PROMPT FROM DATE} to {?PROMPT TO DATE} or {AR_InvoiceHistoryHeader.InvoiceDate} in DATEADD("yyyy",-1,{?PROMPT FROM DATE}) to DATEADD("yyyy",-1,{?PROMPT TO DATE}))
|
IP Logged |
|
|