I created one report with date parameters in ssrs - reporting-services

I created the report with date parameters like startdate and enddate (for 1 year list) and two more parameters sdate and edate (for 3 months list)
so now i got a requirement like
i need to display a drop down list like: 1 year and 3 months
if i select 1 year , i have to see from current date to last year list ...
same for 3 months also and i created one more parameter duration in that parameter , i mentioned available values as 1 year and 3 months for drop down purpose.
so how this date parameters can reflects to that drop down list names ?

Related

How to generate get result from DB when range is provided for searching String column in database?

I have requirement of getting data from database having column as below:
id int(11) PK
quarter varchar(45)
year int(11)
Quarter can take value of yearly quarter as String e.x. Q1 , Q2 , Q3, Q4.
Year can take value from 2011 to 2014.
Requirement:
User will input range i.e. for Quarter as Q1 and Q3
User will inout range i.e. for Year as 2011 and 2013.
We have to return the data that is for Quarter in Q1, Q2, Q3 and Year in 2011,2012 and 2013 and ignore others. Likewise user can input any range.
Please help suggest how can I build generic SQL query for getting the result set?
Since the alphabetic order of the quarter coincides with the chronological one, you might as well use:
SELECT *
FROM your_table
WHERE quarter BETWEEN :Qfrom AND :Qto
AND year BETWEEN :Yfrom AND :Yto
Where Qfrom, Qto, Yfrom and Yto are the parameters provided by the user
SELECT * FROM YOURTABLE
WHERE CONCAT(CAST(YEAR AS VARCHAR), QUARTER) IN (:QuarterList)
Then supply a list to the parameter in the form '2014Q1', '2014Q2' ...

drillthrough month and year grouping error

I used the query below to create a parameter for a drillthrough in my ssrs.
SELECT DISTINCT month([OrderDate])AS 'Month',
FROM cob_adhoc
where datepart(MONTH,[OrderDate]) = #month
group by year([OrderDate]), month([OrderDate])
in my report, i have columns for year and month and other data. The month column has the textbox action to lead to the selected month in another table.
My problem is say someone clicks June in 2014, it brings out data from june from all the years on the table and not the year in the report column.
You will need to create a calculated field in your dataset with the combined values of
CalcMonthYear=CSTR(Fields!Month.Value) + CSTR(Fields!Year.Value)
Then in you label's action don't go to [Month] instead go to [CalcMonthYear]

dynamic query for multiple items from a single record from one table

I have a table (arealist) which has an ID field and multiple fields for tracking membership by year (M2012, M2013, etc) where each year's value is Yes or No. I can build a query to extract the fields I want (SELECT M2011, M2012, M2013, M2014 FROM arealist WHERE ID = 675;) but the fields will be growing in the future years adding M2015, M2016, M2017, etc.
HOW can I build a dynamic query that extracts the current Year info plus 4 years back.
Example: EndYear = 2014 - need 4 years back so answer will be M2011, M2012, M2013, M2014).
SELECT ??? FROM arealist WHERE ??? RANGE (BegYear to EndYear) AND ID = 675;
You should make the year a proper field, changing 1 row with columns M2011, M2012, M2013, M2014,ID to 4 rows with columns M, YEAR, ID (YEAR takes integer values from 2011 to 2014).
Next year, you add one row for each ID with YEAR=2015, and so on, without changing the table definition or your code:
SELECT M from AREALIST where ID= ? AND YEAR >= ? AND YEAR <= ?

get data for the year within from and to dates

I have the following query which gets year,Sum data between from and to date.
It works perfectly.
SELECT strftime('%Y',Date), SUM(Amount)
from table where (Date between '2008-08-01' and '2012-07-31')
GROUP BY strftime('%Y',Date)
I am displaying the sum on a bar chart.
Now If I click on the respective year it should show all the transactions till the "To Date" for that year or if the value is smaller than "To date" then the entire year's transaction.
For Eg: In the example above it displays Sum From Date : 2008-08-01 and To Date: 2012-07-31 .
If the user taps on the year 2012 bar column it should show transactions till the date 2012-07-31 and not for the entire year but if the user taps on 2011 it should transaction for the entire year as the TO Date is greater than 2011 year.
Same for the year 2008, it should display data from "2008-08-01" not the entire year and if I tap the bar column of that year it should show the transactions from that particular date till the end of the year and not for the entire year.
I have the query below which returns wrong value .
SELECT strftime('%Y',Date) ,*
from table where (Date between '2011-08-01' and '2012-07-31')
and strftime('%Y',Date)='2012'
GROUP BY strftime('%Y',Date)
This returns only one row for the date 2012-01-01 not all the values for the year 2012 till 2012-07-31.
Basically I would like to change only year in the following query and rest should be same. strftime('%Y',Date)='2012'
I don't know how to fix it or How to go about it w.r.t the above requirement.
Please help me fix it or Any Alternative. Thanks in Advance.
You don't need GROUP BY
SELECT strftime('%Y',Date) ,*
from table where (Date between '2011-08-01' and '2012-07-31')
and strftime('%Y',Date)='2012'

MSAccess - Design query to group by anniversary date

Lets say I have a table with these fields
LeaveDate
LeaveType
I want to write a query that groups by an annivesary date.
For example say 8th Feb.
So for this year any dates after 8 Feb would be "2010" and any dates before 8 Feb would show "2009".
I want this to occur for all years data.
Understand??
Malcolm
Here is how I did it
SELECT Year([tblFoo]![Leave_date])-IIf(DateDiff("d",[tblFoo]![Leave_date],DateSerial(Year([tblFoo]![Leave_date]),2,8))>0,1,0) AS Year_group, Count(tblFoo.ID) AS CountOfID
FROM tblFoo
GROUP BY Year([tblFoo]![Leave_date])-IIf(DateDiff("d",[tblFoo]![Leave_date],DateSerial(Year([tblFoo]![Leave_date]),2,8))>0,1,0);
This counts the number of records for each “Year”. We use something similar for working out birthday years which change from person to person. In that case use can just replace the fixed 2 and 8 with the month and day they were born
You could create a query with a calculated column for anniversary date, then group by that column.