EXPLAINATION
I have 2 parameters in SSRS report: Year and Month
AVAILABLE VALUES
Available values are selected from dropdown list (could be multiselected values).
Year available values are selected with SQL query;
Month available values are from 1 to 12.
DEFAULT VALUES
Default values for now are:
Year expression: =YEAR(NOW())
Month expression: =MONTH(NOW())
WHAT I NEED
If for parameter Year user change default value and select 2 or more values (i.e. 2015 and 2016) It automatically should select all values for Month parameter (select from 1 to 12)
Also I have custom value in both parameters: All, if value All is selected It's the same as select all values from the list.
How can I achieve It?
Related
I need to build a report on Accounts where my criteria should contains
Records that are created from yesterdays 7 AM To todays 7 AM
Please help me to solve
Create a new formula field on the record of type "Checkbox" containing the following:
AND(DATEVALUE(CreatedDate) >= TODAY() -1,
OR(
AND(
DATEVALUE(CreatedDate) = TODAY() -1,
TIMEVALUE(CreatedDate) >= TIMEVALUE("07:00:00.000")
),
AND(
DATEVALUE(CreatedDate) = TODAY(),
TIMEVALUE(CreatedDate) <= TIMEVALUE("19:00:00.000")
)
)
)
(you might need to adjust the time values (07 and 19) to adjust for your time zone as formula's use GMT values)
Next filter your report on accounts that have this checkbox set to TRUE.
If it's child records you are looking for, you need to do a few extra steps, one of the options than is to create a report filter (or type) that only shows accounts that have at least one record with this checkbox set to TRUE.
I have two parameters in my Report - Begin and End Dates which are of Date/Time type. When I select the Begin Date from the Calendar, how do I automatically show dates equal to or greater than Begin Date for the End Date calendar? I would like the have the user the ability to select only End dates after Begin date.
This could be a potential workaround going off the comment I made to your question. You would need three datetime parameters:
-#1 StartDate
-#2 EndDate
-#3 EndDate2 - make this hidden
The StartDate and EndDate (#1 and #2) are for users to select. For the report, we will use StartDate (#1) and EndDate2 (#3) to filter.
You can set the default for StartDate/EndDate however you would like. For EndDate2, if the user selects a date prior to the start date, default the end date that gets passed to the report. We set this by adjusting the default value for EndDate2 parameter with the IIF function to compare the user input dates.
Add this to default value for EndDate2 parameter:
=IIF(Parameters!EndDate.Value < Parameters!StartDate.Value, Parameters!StartDate.Value, Parameters!EndDate.Value )
I need to build a report that has custom quarter periods as shown below:
Quarter 1 - Jul, Aug, Sep
Quarter 2 - Oct, Nov, Dec
Quarter 3 - Jan, Feb, Mar
Quarter 4 - Apr, May, June
I'm a bit lost on how to approach this as I need to create a parameter where if they select quarter 1 it should only display data for the corresponding months.
Is there anyone that can suggest something?
Script looks as follows:
SELECT
ATD.TrnYear,
ATD.TrnMonth,
ATD.Invoice,
ATD.InvoiceDate,
ATD.Salesperson,
ATD.Customer,
ATD.StockCode,
ATD.ProductClass,
ATD.QtyInvoiced,
ATD.NetSalesValue,
ATD.CostValue,
AC.Name
FROM
ArTrnDetail ATD
JOIN ArCustomer AC ON ATD.Customer = AC.Customer
So I would need to add how to distinguish when the user selects the quarter.
Much appreciated.
Assuming your ATD.TrnMonth column use integer to represent months, I added an additional column to your query to indicate quarters (QTR). Also added the condition which will filter your result based on the user selection (WHERE Qtr = #quarter). This will be your dataset query.
SELECT *
FROM
(SELECT
CASE
WHEN ATD.TrnMonth IN (7,8,9) THEN 1
WHEN ATD.TrnMonth IN (10,11,12) THEN 2
WHEN ATD.TrnMonth IN (1,2,3) THEN 3
WHEN ATD.TrnMonth IN (4,5,6) THEN 4
END as Qtr,
ATD.TrnYear,
ATD.TrnMonth,
ATD.Invoice,
ATD.InvoiceDate,
ATD.Salesperson,
ATD.Customer,
ATD.StockCode,
ATD.ProductClass,
ATD.QtyInvoiced,
ATD.NetSalesValue,
ATD.CostValue,
AC.Name
FROM ArTrnDetail ATD JOIN ArCustomer AC ON ATD.Customer = AC.Customer
) as ArTrnDetail
WHERE Qtr = #quarter
In your report builder, create paramater with these settings:
GENERAL TAB
Name: quarter
Prompt: (whatever you want displayed for user)
AVAILABLE VALUES TAB
select Specify Values, and add 4 available values.
The label should be 1, 2, 3, and 4 (quarters) and the value should be the labels you want displayed in your dropdown list. Make sure the labels correspond with your values (quarters)
DEFAULT VALUES TAB
For example, when the report runs and you want the report to default to the first quarter. Select Specify Values, put 1 in the value. Leave this tab if you don't want defaults.
Note - This is the configuration for a single value dropdown. If you want the user to be able to select multiple values. In the "General" tab of the parameter, check "Allow multiple values" and change your query condition from WHERE Qtr = #quarter to WHERE Qtr IN (#quarter).
You need to map your data to a Date Dimension.
When you have done that you would have a fact table that can be joined to your date table. Either by an surrogatekey or a businesskey.
An example could be.
Query for Report
Select SalesAmount,SalesDate,Employee from fact.Sales S
inner join Dim.Datedimension d on s.SalesDate = d.Date
where d.QuarterNo = #DateParameter
Query for filter
Select distinct QuarterNo,QuarterLabel(Your Quarter 1 - Jul, Aug, Sep) From Dim.Datedimension
QuarterNo will be your value in parameter settings.
QuarterLabel will be your label.
Remember to adjust your date dimension to match your special quarters.
Report has two parameters
DateFrom
DateTo
DateTo set to "Always Refresh"
I have the following expression for DateTo - Default Values - so that it will dynamically default to the last of the month set by DateFrom
=DateSerial(Year(Parameters!DateFrom.Value), Month(Parameters!DateFrom.Value), "1").AddMonths(1).AddSeconds(-1)
However, the field doesn't update.
It shows the correct last date of month when DateFrom is selected the first time.
If DateFrom is set to 15/02/2019 then DateTo will show "28/02/2019 23:59:59".
But if you subsequently change DateFrom to a different month, DateTo doesn't update - still shows "28/02/2019 23:59:59".
I have just added these Parameter properties
1) data type -> date/time and allow nulls
2) available values -> specify values -> label and value as
=DateSerial(Year(Parameters!Datefrom.Value), Month(Parameters!Datefrom.Value), "1").AddMonths(1).AddSeconds(-1)
3) Advanced=always refresh. and checked notify me box.
This works the moment i change param 1 ('Datefrom') i get new dateto as last date from month.
Are your settings matching this?
I have cascading parameters like: Year > Company After choosing Year value, Company parameters are refreshed.
So for example If I choose 2016, but at this year no data, Company parameter is empty (no values) and report says that parameter can't be blank (I've checked "Allow blank values """, but It not working with multivalued parameters) See image below:
How can I load report with message like: "Sorry, there is no data"? Or provide any default value for Company parameter if there is no other values? Have you any ideas?
One solution is to make your Year parameter data-driven, from the same table as your companies. Make a new dataset like the one below, and use it as the available values for your Year parameter.
SELECT DISTINCT year
FROM companies
WHERE report_relevant = 'Yes'
ORDER BY 1
This limits the users to only pick years where valid companies exist. As soon as a 2016 company is added to your data, the report will automatically include 2016 as a Year parameter option.
You could use a UNION to add an extra row of data to your parameter, but Count() your valid companies so the extra row is only included when no other companies would be.
SELECT company_id, company_name
FROM companies
WHERE year = #Year
UNION
SELECT '-1', 'No companies in ' + #Year
WHERE (SELECT Count(company_id) FROM companies WHERE YEAR = #Year) = 0