Conditional formatting in a matrix - reporting-services

This is my matrix in design view
The Last column has the following expression in it. This brings back the latest date for that particular row.
=Format(Max(Fields!DateTime.value),"dd/MM/yyyy HH:mm:ss")
I want to colour the ones that have occurred within the last 6 weeks
=IIF(DateDiff(DateInterval.Day , Fields!DateTime.Value, Today()) <=42, "#f5c6c8", Nothing)
This brings back the following
For some reason it's working for some fields and not others

Right managed to figure this out, needed to put max in my expression
=max(IIF(DateDiff(DateInterval.Day , Fields!DateTime.Value, Today()) <=42, "#f5c6c8", Nothing))

Related

SSRS Matrix columns show currrent month

I'm stuck with a problem in SSRS 2012 that maybe is very simple:
I have a matrix with a group row (employee) and a group column (last 12 months); the values are COUNT(practicesDone) - i.e. the amount of practices worked.
I want the matrix to show an extra column on the right (after all the columns of the months, and clearly outside the column group) with again the number of practices for the current month.
Is it possible to achieve that?
thank you in advance!
You can do this, it's pretty simple.
I have assumed that your dataset contains a column that has a date for each entry and that the data returned only covers 12 months so the same month would not appear for different years. If your data does have multiple years, look at the second expression below.
Right-click your month column and then to "Insert Column --> Outside Group - Right"
Now set the expression for the text box to
=COUNT(IIF(MONTH(Fields!myDateColumn.Value) = MONTH(TODAY()), 1, Nothing))
You could swap COUNT for SUM and it should do the same thing but either will work.
All we are doing here is comparing the all data in scope which, due to the placement of the text box means the scope is the entire rowgroup. Then for all that data, check if the month matches the current month, if it does set it to 1 is not set it to nothing then count/sum all results. Count conveniently ignores 'nothing'.
If you data covers more than 12 months then you can still do this but you'll have to add a bit more to handle years and months like this.
=COUNT(
IIF(
MONTH(Fields!myDateColumn.Value) = MONTH(TODAY())
AND YEAR(Fields!myDateColumn.Value) = YEAR(TODAY()),
1,
Nothing
)
)

Auto populate dates of the week Paginated reports

Good day
I am very very new two paginated reports so forgive me if this is a silly question
I have a report that displays values for Mondays to Fridays based on the date selected from a date picker.
So basically
You select a date (Example 24 Nov) and the following table is displayed based on values pulled from SQL.
Now my question is how do I display the dates of the weekdays too?
So if the date selected is Thursday 24 Nov, in the column headers under the week day names it should give the corresponding date i.e Monday-21/11/2022, Tuesday - 22/11/2022, etc.
Below is a little snippet of the data
So the date picker is based on the ReportingDate column. The rows of the matrix consist of Region and Country and the values are the sum of Monday-Friday.
Any guidance would be greatly appreciated.
Edit: The day names are not obtained via an expression in SSRS. They carry over from the column headers in the data set.
Assuming you have some expression to get the actual day name already, you can leave that bit as it is.
Now, double click the column header "cell"/textbox to get a cursor in there, then click at the end of the existing fields/expression.
Now just put a space in and then right-click and choose "Create Placeholder". The placeholder dialog will appear.
This placeholder acts almost like a separate textbox to you can put whatever you want in there, click the '[fc]' button next to the Value property and then set this to whatever you want, e.g. =Fields!ReportingDate.Value.
Now go to the "number" tab on the same dialog box and set the format to the required date format.
If you want to edit this later, just double click the cell again but this time right-click the placeholder and choose properties.
The other way of doing this would be to add another row to your header and set that to be the date instead but then you have to mess around removing borders etc., sometimes this can be easier if layout is an issue but you have a couple of options at least now.
I managed to figure it out with the help of the following post.
These are the steps I followed
Get the date of the first day of the current week (Sunday's date) using the formula explained in the link
DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value))
Use DateAdd to add the corresponding number of days to get to a required weekday. That is for Monday add 1, Tuesday add 2,...
DateAdd("d",1,DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value)))
Format datetime to date and add new line to insert date below day name
="Monday" + Environment.NewLine + FormatDateTime(DateAdd("d",1,DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value))), DateFormat.ShortDate)

Using IIF and DATEPART in SSRS to highlight the first of the month in date column

I have a date column that shows the days on each month. I need to highlight the first date of the month for each month. Example 07/01/2021 would be highlighted, 08/01/2021 would be highlighted; all other dates in the month would not. This is the code I am trying:
=iif(DatePart(DateInterval.Day, Fields!Date.Value, 1, "Yellow","Transparent"))
but it is not working. Any help would be appreciated.
Your expression is incorrect. The Datepart should be compared to 1 and then IIF will use either the 2nd (true) and 3rd (false) argument.
=IIF(DatePart(DateInterval.Day, Fields!Date.Value) = 1, "Yellow", NOTHING)
Also, I think it's a old bug where "Transparent" is not a valid color even though that's what the GUI gives the user when clicking on NO COLOR. Either use "White" or NOTHING (the SSRS null value)

SSRS Target Line

I would like to re-create a line chart in SSRS like the one below (created in excel)
Target vs Revenue
I can re-create the running value (green line - revenue) but I have no idea how to do the straight target line (grey one) that should end at the end of the current month. The value for this line comes from a text parameter (I type in the target for current month manually), so ideally this should be a running value of the parameter number divided by the number of days for this month ending on the last day.
Can I have an angled StripLine to achieve that or shall I use an expression, if so, can you help me to build it, please?
Thank you for your help.
This answer assumes you know what month you are running the report for and you can therefore determine the number of days in that month. I won;t cover that here, ask a new question if you can't do that.
To create your target line, open your dataset properties, click the 'Fields' tab and Add a new field.
Call the new field Target or whatever you want and hit the fx button next to field source. Set the field source to following expression.
=(Parameters!Target.Value/31) * DAY(Fields!myRevenueDateField.Value)
You will just need to swap out the 31 for the actual number of days in the month, and the correct date fields from your dataset.
I used some sample data in my test with a target of 3000 and got the following result.

Adding two date stamps into a single SSRS expression/cell

This is all done in Microsoft SQL Server Report Builder
So I have a large data set that contains Work orders and then their 'type/craft'. Each craft is then broken down into each row so that you can see how many work orders are still open in the certain craft. At the top of the page, It list, WO's 1-2 Past Due, WO's 3-5 Past Due, WO's 6-10 Past Due... etc, till you reach 30 days+
I then have an expression inserted that will tell you what date the 1-2 days is... However, I am having trouble making the expression value be 2 dates or an in between date.... For example, I have =DateAdd("d", -1, Now) inserted which will give me the date from 1 day back, however, I would ALSO like it to show 2 days back.... So instead of ONLY saying 6/13/2018... it would say 6/12/2018 to 6/13/2018
I guess I could go back and edit my SQL code to automatically do the dates, however I thought it would be easier to use the report system.
You would want your expression to be something like this:
=DateAdd("d", -2, Today()) & " to " & DateAdd("d", -1, Today())
If you need the time as well you would want to use Now instead of Today, but based on your question it seems you are only interested in the dates, so this should return exactly what you are looking for.