I am trying to create a finance report based on date range parameters selected. There are 35 hours available each week. If a person selects 2 weeks in the date parameters we want to calculate 35*2 as total hours available.
Is there a calculation that will help with this?
I would store the value 7 as a hidden parameter HoursPerWorkDay and then do the calculation based on work days between your 2 date parameters.
=((DateDiff(DateInterval.day, Parameters!StartDate.Value, Parameters!EndDate.Value) + 1)
- DateDiff(DateInterval.WeekOfYear, Parameters!StartDate.Value, Parameters!EndDate.Value)*2)
* Parameters!HoursPerWorkDay.Value
Related
Im trying to average the past 5 rows in my table i created in SSRS grouped by date(Monday of every week). Ive tried runningValue however it looks back at all the past rows for each group. Is there a way to limit the scope to just the past 5 rows or weeks for each Date group.
Thanks
I would accomplish this with grouping. I don't know what your dataset is like but I assume it is a SQL query you can modify. The easiest solution would be to add a week number column to your query. For example:
SELECT datepart(week, YOURDATE) as WeekNumber
More info on datepart:
https://learn.microsoft.com/en-us/sql/t-sql/functions/datepart-transact-sql?view=sql-server-2017
Once you have a week number, use the table creation wizard in Report Builder and add WeekNumber as a row group. This will group your values by week number and give you a total under each week. You can change the total by double clicking and making it AVG() instead of SUM().
Note: If you already have each 5 day period in a group, you should be able to right click that and add total. At which point you can just change the SUM to AVG there.
I have a report with 7 datasets and 7 tables all exactly the same except the datasets each have a slightly different where clause
where datepart(DW,[Start Time]) = 2
The idea is to show data for each monday this month in one table and each tuesday in another and so on. So one table uses the monday dataset (above) one uses
where datepart(DW,[Start Time]) = 3
for tuesday and so on. What I really want to do is have the report decide which dataset to use first based on what day the first of the current month was. So this month (April) the 1st was a saturday so I'd like my leftmost table to use the dataset
where datepart(DW,[Start Time]) = 7
Then the one after it to be sunday and so on. But next month (May) I want it to automatically switch to using the monday dataset in the first table as the 1st will be a monday.
Is this possible?
One possibility is to use a sub-report that uses a single dataset. This dataset would have a where clause that takes a parameter
WHERE DATEPART(DW, [Start Time]) = #dayOfWeek
Replace your current 7 tables with 7 copies of the same sub-report but change the parameters to be based on the first day of the month so you first sub-report would have the parameter passed as
=WeekDay(dateserial(Year(now()), Month(now()), "1"))
the second sub report would have the parameter passed as
=WeekDay(dateserial(Year(now()), Month(now()), "2"))
and so on...
I'm trying to sum a net balance based on the earliest date in an SSRS report. In this case there are only 2 dates, but there can be more dates not more than 7 days.
Here's a sample of my data:
Here's what I'm trying to get with the earliest date of 10/26/15:
I've tried the following code, but not able to get this to work:
=Sum(IIf(DateDiff("d",Fields!SettleFullDate.Value,today())>=7
and DateDiff("d", Fields!SettleFullDate.Value, today())<7
and Fields!SETTLEBALANCE.Value>0), Fields!SETTLEBALANCE.Value, 0)
Update: I tried the code below and keep getting an error on the report. Could it be that I need to change the date field to an integer?
Thanks in advance for your help!
To compare the sum of values of two dates, the maximum and minimum in a set you can use the following equation
=Sum(iif(Fields!myDate.Value = Max(Fields!myDate.Value), Fields!myVal.Value, 0))
-Sum(iif(Fields!myDate.Value = MIN(Fields!myDate.Value), Fields!myVal.Value, 0))
This Sums all the values that match the maximum date in the dataset together, and sums all the values that match the minimum date in the dataset together, and takes one from the other.
It is irrespective of which dates you ask to be received, the above approach will work only against the records that you return to SSRS. So if you have a filter (WHERE clause) to return records between Date1 and Date2 this will still apply (Note - don't actually use 'Between' in the query)
Rather than using the maximum and minimum dates as listed here, you could also calculate a date similar to your original approach using
dateadd("d", -7, Fields!MySpecificDate.Value)
And insert that to the expression above.
Hopefully this is what you require - if not please let me know.
We have a SSRS Matrix report with the following areas
RowGroup:MonthYear
ColumnGroups:Campaign,Year,Processed
Detail:Sum(Processed)
We have added a single column outside of the ColumnGroup for and expression that will show the increase/decrease of current year processed records over previous year processed records
The data is shaped like this:
lYear, MonthYear, Campaign, Processed
2014, JUL-10, XYZ, 120
2015, JUL-10, XYZ , 60
So the formula is basically CurrentYearProcessed/PreviousYearProcessed which in this example would yield 50%
So how can we specify this when writing the expression?
Just use IIF to filter for the year:
=SUM(IIF(FIELDS!lYear.VALUE = YEAR(GETDATE()), FIELDS!Processed.VALUE, 0) / SUM(IIF(FIELDS!lYear.VALUE = YEAR(GETDATE()) - 1, FIELDS!Processed.VALUE, 0)
This checks your lYear field to see if it's the same as the current year [ YEAR(GETDATE()) ] and sums the Processed field. Then it divides by the previous year's SUM using similar logic.
I'm producing a line graph within SSRS using SQL Queries. I have a line graph with 4 datasets (3 using lookup function).
My queries calculate values for each month of current year. As we are only in June, values of months from July to December are 0. I don't want that they were displayed on graph and on axis.
Can anyone point me in the right direction? I've tried to add a filter to the category group for the axis but this hasn't worked
Expression: Month_field
Operator: <
Value: =Month(Today())
my sql query is a build up of months for this year so I can get a result for all months ( I was having Issues returning 0 as a value for a month)
eg..
(SELECT * FROM (VALUES(DATENAME(month,'2015-01-01'),1)
,(DATENAME(month,'2015-02-01'),2)
,(DATENAME(month,'2015-03-01'),3)
,(DATENAME(month,'2015-04-01'),4)
,(DATENAME(month,'2015-05-01'),5)
,(DATENAME(month,'2015-06-01'),6)
,(DATENAME(month,'2015-07-01'),7)
,(DATENAME(month,'2015-08-01'),8)
,(DATENAME(month,'2015-09-01'),9)
,(DATENAME(month,'2015-10-01'),10)
,(DATENAME(month,'2015-11-01'),11)
,(DATENAME(month,'2015-12-01'),12)) AS Mnth(" Month ",MnthSort)) AS M
followed by the below to returnvalues greater than 1st fay of current year and less than 1st day of current month
WHERE Received1Date >=dateadd(mm,datediff(mm,0,getdate())-12,0)AND Received1Date < dateadd(mm,datediff(mm,0,getdate()),0)
My issue is when using my query in SSRS on a line graph all months display on Axis and all future results are 0 - I know this is expected because of my query but just wondering if there is something I can do to the graph within SSRS to exclude all future months?
Why don't you filter the data in your query?
select values
from table
where transaction_date >= Getdate()
this way those future months are not options to be displayed.