conditional formatiing rolling 6 weeks - reporting-services

I would like to change the background color of a cell in my table based on incidents that have occurred within the last rolling 6 weeks. It would start from present date.
Incident date
g 14/01/2018
e 15/01/2018
a *02/02/2018
b 05/02/2018
c 02/03/2018*

Set the background property of the cell or row to something like this.
=IIF(DateDiff(DateInterval.Day , Fields!YourDateColumn.Value, Today()) <=42, "Yellow", Nothing)

Related

conditional formatting by date

I have the following table in my report
Address SeenDate
stack street 2015-01-02
over lane 2016-03-15
flow way 2017-05-12
I would like to highlight addresses in green that have got a 'SeenDate' within 12 months, I think this will need to be a rolling 12 months. So from the table above 'flow way' will be highlighted in green.
To do a conditional on your date value to highlight records that are within 12 months of the report execution date, you can compare the date value with a year ago from today using iif in the Fill expression of the textbox:
=iif(Fields!SeenDate.Value >= Today().AddYears(-1), "Green", "Red")
Also a note to add that Today gives you the date for today and Now gives you the date and time of right now, depending on how precise you want to be.

SSRS bar char x-axis formatting

I've got a chart that overlays the past 2 years (taken from the current date) worth of data onto a 1 year range, so the monthly values can be compared between years. The x-axis values are week numbers.
Currently, I've got the x-axis like this:
-------------------- etc
1 2 3 4 5
What I want is to start the x-axis with the week for the earliest date in my data set, so my x-axis looks like this:
--------------------------...-------
49 50 51 52 1 2 3 ... 47 48
How do I get the chart control to get my x-axis to appear like this?
You need to have another column that contains the year, sort by this first, then the week number, then only display the week number in the axis.
So assuming your data is something like:
You would apply two sorts to the category group, Year then Week, but only display Week in the axis label.
I have left all the Category Axis Properties as default:
This gives the expected result:

Show month names against Numeric Values

I have a dataset which looks like this
ProjectName MonthsThisYear CompletionDate
ProjectA 5 5/1/2013
ProjectB 7 7/15/2013
ProjectC 10 10/21/2013
I want to bar plot a graph where Y axis is project Name and X axis is January 2013, February 2013 ... December 2013.
Now the bar against projectA must be 5 units long, ProjectB is 7 units long and the bar for Project C should be 10 units long.
so that people can see that ProjectA is completed in May, ProjectB is completed in July and project C in October.
How can I plot this graph?
currently I can plot this correctly... but the X-Asix has 0, 2, 4, 6, 8, 10, 12 on it rather than month names.
I am on SSRS 2008 R2.
This is what I see right now
I just want to see month names and year on X axis.
Maybe some more question detail would be useful, but here's one way that works with your data:
The main issue we're facing is that typically a date is the category, but in this case it's actually the Data value, which gives us less control over the labels compared to a category group.
First, set up a chart with a Category Group based on ProjectName, and a Data expression like:
=DateSerial(Year(Fields!CompletionDate.Value), Month(Fields!CompletionDate.Value), 1)
i.e. the first of the month of each CompletionDate value, otherwise your bars will be between months.
Next, we need to sort out the X axis:
In my example I set Minimum to:
=DateAdd(DateInterval.Month
, -1
, DateSerial(Year(Min(Fields!CompletionDate.Value)), 1, 1))
i.e. December for the last year. Set Maximum to:
=DateSerial(Year(Max(Fields!CompletionDate.Value)), 12, 31)
i.e. the end of the year.
Set Interval to 1 and Interval Type to Months.
Format the X Axis to MMM yyyy.
Looks OK:
If you can actually add a Year column with a value 2013 or whatever, pretty much all of the expressions above can be simplified. For example, I've ignored MonthsThisYear, but if you have a Year column you can build the start of the month value based on MonthsThisYear and Year.

Using the NOW Function In Access

I am setting up a code to pull all employees hired within the last 2 years who got a certain rating. I have been looking into the YEAR(NOW()) function but I am having a difficult time setting it up. I need to use the NOW function because I need it to pull the data from the time the user access the query. The ratings are completed every following feburary (i.e 2013 ratings will be completed in February of 2014) so it needs to read something like
YEAR(NOW()-12) but it
This way if I were to run it today it would go back and pull the ratings for 2012 and 2011 since 2013 have not yet been completed.
My whole code looks like:
SELECT dbo_v_TMS_QPR_01_Score.TMS_ID, dbo_v_TMS_QPR_01_Score.QPR_Year, dbo_v_TMS_QPR_01_Score.Final_QPR_Score
FROM O867IA_VJOBHST INNER JOIN dbo_v_TMS_QPR_01_Score ON O867IA_VJOBHST.SYS_EMP_ID_NR = dbo_v_TMS_QPR_01_Score.GEMSID
WHERE (((dbo_v_TMS_QPR_01_Score.Final_QPR_Score)>="1.25") AND ((O867IA_VJOBHST.EMP_ACN_TYP_CD)="HIR") AND ((O867IA_VJOBHST.REC_EFF_STT_DT)=Year(Now()-12)))
GROUP BY dbo_v_TMS_QPR_01_Score.TMS_ID, dbo_v_TMS_QPR_01_Score.QPR_Year, dbo_v_TMS_QPR_01_Score.Final_QPR_Score;
But I keep getting the error: INCONSISTENT DATATYPES: EXPECTED DATE GOT NUMBER (#932)
What you have does not work. It subtracts 12 days off the current date/time and then converts it to the year. Thus, it returns 2013.
Use the dataadd() function. The following is a blank query in the query designer.
I am asking for today's date minus 12 months. See output below.
I would THINK you want something like:
If Month(Now()) > 3 then 'If it's after Feb, we want the last 2 years
LastDayOfPrevYear = DateAdd("d", -1, DateSerial(Year(Now()), 1, 1))
Else 'If it's before March, we want the 2 years prior to last year
LastDayOfPrevYear = DateAdd("d", -1, DateSerial(Year(Now())-1, 1, 1))
End If
SELECT dbo_v_TMS_QPR_01_Score.TMS_ID, dbo_v_TMS_QPR_01_Score.QPR_Year, dbo_v_TMS_QPR_01_Score.Final_QPR_Score
FROM O867IA_VJOBHST INNER JOIN dbo_v_TMS_QPR_01_Score ON O867IA_VJOBHST.SYS_EMP_ID_NR = dbo_v_TMS_QPR_01_Score.GEMSID
WHERE (((dbo_v_TMS_QPR_01_Score.Final_QPR_Score)>="1.25") AND ((O867IA_VJOBHST.EMP_ACN_TYP_CD)="HIR") AND ((O867IA_VJOBHST.REC_EFF_STT_DT)>=DateAdd("m", -24, LastDayOfPrevYear)))
GROUP BY dbo_v_TMS_QPR_01_Score.TMS_ID, dbo_v_TMS_QPR_01_Score.QPR_Year, dbo_v_TMS_QPR_01_Score.Final_QPR_Score;
This will give you a "rolling" 24 month timespan from the last date of the previous year.
This may need a little tweaking, but it should be, at the very least, extremely close.

SSRS - Subtracting column values without knowing row details

Got a question regarding SSRS. Using 2005 version.
I've got 2 tables in my report, one with the current months data and one with data for the last 3 months.
The last 3 months table always returns 3 rows, 1 row for each month. What I want to do is subtract a value from the 2nd oldest month, basically it will always be row 2 of the table with the equivalent column in the current months table. Hope this kind of makes sense.
I will use an example here;
Table 1
Month Value Var
August 5 ?
Table 2
Month Value
July 4
June 7
May 10
I want to use the Value in Table 1 and subtract the Value of the June column in Table 2 therefore 5 - 7, returning the value -2.
There is a month parameter so the Tables data would change depending on the month but it was always be the 2nd rows Value column that I want to use.
Is this possible in SSRS?
Thanks
Method 1:
It is better to solve this in the SQL (dataset) then in the report design.
If data comes from two different tables then
Select C.Month, C.Value, (C.Value - L.Value) AS Var
From CurrentMonthData C
Left JOIN (Select * Last3MonthData where Month = CurrentMonth - 2) L
ON 1=1
If data comes from same table
Select C.Month, C.Value, (C.Value - L.Value) AS Var
From (Select * MonthData Where Month = #CurrentMonth) C
Left JOIN (Select * MonthData where Month = #CurrentMonth - 2) L
ON 1=1
Method 2:
If you prefer to do it in the Report Itself you can use ReportItems collection.
In the variance text box value put
=ReportItems!CurrentMonthValueTextBox.Value - ReportItems!Prev2MonthValueTextBox.Value
HTH.
you may try using LookupSet or MultilookupSet