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]
Related
I have an SSRS report that has all 12 months as columns and one more column called "Year". I already have a condition set that takes the current month of the report run date and displays only the months that have passed. For example, the expression looks like this for March =IIF(Month(today()) < 3, True, False).
Now I have to tie this to the Year column as well. The condition is- if the Year column has years prior to the current year, the condition above should not apply. So, if I am running 2020 data today, all 12 month columns should appear. If I am running 2021 data, I should only see the January column. Can some one please help me with this? And yes, there will only be one year in the "Year" column. The data will never have more than one year.
Thank you.
Edit 1:
If the report is run for 2020, the data should look like this on the report.
If it is run for 2021, only the YEAR and JANUARY columns should appear. Starting February of this year, YEAR, JANUARY, AND FEBRUARY should appear.
As your dataset is not normalised, you will have to set the column visibility on each column as you are doing already.
Try using the following expression. (using March as an exmaple)
=(Month(today()) < 3 AND MAX(Fields!Year.Value, "DataSet1") = YEAR(Today())
Note: The "DataSet1" reference is the name of your dataset. It is case sensitive and must be enclosed in quotes as shown above.
There is no need for the IIF() expression as the above will return true if either condition is met.
Alternative
If your data was normalised (you may be able to edit your dataset query) and looked something like this...
Year Month Amount
2021 1 10
2021 2 15
Then you could simply use a matrix instead of a table, and have a column group by month. There would be no need to set visibility on anything as the data simply is not there so no column would be rendered for the months with no data.
I've a column with values for each month of the year.
Then in parameters of my report i would be able to set the month.
SSRS should return this column with values for each month of the year (like if there's no parameter) but the sum at the bottom of this column should return the sum of the value from the beginning of the year to the selected month.
Is it possible?
Yes. If I'm understanding correctly, you want something like the image below:
Assuming your MonthYear column is a DateTime and your month parameter is an Integer, you can use an expression like the following to conditionally sum the total based on the parameter value:
=Sum(IIf(Month(Fields!MonthYear.Value) <= Parameters!Month.Value, Fields!Value.Value, 0))
I have a requirement of creating an ssrs report that needs to be showed in a matrix in this format
Dataset includes the following fields
year, month, values, account name
report format is something like this:
current month | month ( last year)| difference in %
account name
how do I calculate field for month of previous year? because SSRs does not have case or where logic inbuilt?
If you are doing this in your dataset you can do
DATEADD(YY,-1,COLUMN)
This will change your date a year back.
If you want to do this in the Report Side You can create a new column and create a calculated field and use:
=DateAdd(DateInterval.Year,-1,ColumnName)
Same Effect
I need to group within my SSRS report by Fiscal Week, Month and Year. I'm having the user select a date then referencing a created table that houses the fiscal week, month year etc. for that calendar date. How do I group on this within SSRS?
Fiscal Table Sample Data
Calendar_Date: 04/28/2013
Fiscal_Week: 13
Fiscal_Month: 3
Fiscal_Year: 2013
I want the report to display like
How do I do a grouping where I can group on the week and month of the selected date?
You can set up a group to be grouped on multiple fields, though it's not exactly intuitive.
When you add a group you can only choose one grouping expression:
However, when you've created the group you can add more grouping criteria:
Add in all your required fields here and it should group correctly by the various required fields.
I have a Bar Chart that I am trying to limit Sales data to specific Months/Years. I want a SUM of Sales $ for 2012 and a SUM of Sales $ for 2013. The Month Names are formatted like January 2012, January 2013, etc. How can I do this?
You need to choose the 'Category Group Properties' and change it to group by year instead of just date.
Choose 'Category Groups' add a group like say 'dt' for our example which is a date field.
Click the down arrow now next to it and choose 'properties'.
On the 'General' pane select the 'Group on:' portion and click the 'fx' button for a function.
Put this in =Year(Fields!dt.Value)
Click OK
You now are overriding your default grouping and are now grouping by year instead of full date. This process works for months and days as well.
IF your data field for date is not a legitimate date field you need to make sure it is a 'date' or 'datetime' data type first.