I am new to SSRS and am using 2017 version to make some paginated reports in SSRS with SAP HANA as DS.
I have data which looks like:
SO TYPE LABEL Amount CY Sales
A010 10 Sales 2023
A020 20 Total 100
A030 20 Labour 400
A040 30 Shipping 0
Here CY is the CY and Sales are calculated fields where:
CY = IIF(Fields!SO.Values="A020" and Fields!TYPE.Value=20 , Fields!Amount.Value,0)
Sales = Sum(Fields!CY.Values)
Now when I use the above expression I get result for Sales as #Error and CY as NaN.
The data type for both the expressions is default.
Can anyone help me so that I can get values for CY and Sales.
Your expression should be:
= Sum(Fields!CY.Values)
Related
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
I'm creating a SSRS report that shows projected sales for the next 12 months, grouped by ProductID. While the detail cells are showing correctly, the group sums for each month are displaying all sales for the 12 months rather than just the related month.
For example, here are all the table values for a single Product:
ProductID EstimatedDate ProjSales
123A Oct 10/2017 100
123A Nov 15/2017 100
123A Dec 01/2017 100
123A Dec 31/2017 100
However, this is what the report is currently showing for this Product:
Product EstimatedDate Oct 2017 Nov 2017 Dec 2017
123A Oct 10/2017 100 0 0
Nov 15/2017 0 100 0
Dec 01/2017 0 0 100
Dec 31/2017 0 0 100
Total 400 400 400
As seen above, the detailed cells calculate perfectly as each record in the detail section displays a Projected sales value if the Year/Month matches, otherwise it displays 0. Unfortunately, the final row with the "Total" amounts is incorrect as the monthly cells are showing the total of projected sales for all months rather than just the month in question.
Here are my report expressions for December 2017:
Detail Cell:
=IIF(Year(Fields!EstimatedDate.Value) = 2017 AND Month(Fields!EstimatedDate.Value) = 12, Fields!ProjSales.Value, 0)
Grouped Cell
=IIF(Year(Fields!EstimatedDate.Value) = 2017 AND Month(Fields!EstimatedDate.Value) = 12, SUM(Fields!ProjSales.Value), 0)
Any idea how I can change the grouped expression to retrieve the projected sales for each month?
Edit : format code
Use a Matrix.
Add a column group and group by year then month.
Then simply have ProjSales in the detail row group and SUM(ProjSales) in the Group total. There is no need to use expressions to calculate the values.
The column group captions will have to be expressions in order to pull out the month and year from the EstimateDate column. If you have the stored dates in a more conventional format YYYYMMDD etc then it would be easier as I'm not sure any DATE functions will recognise the format you show above.
If you need a more detailed answer let me know. I'm not able to do anything more at the moment.
I want to get the Turn Around Time(TAT) of dates. for example:
I have a createddatetime 2016-11-02 06:21:34.000 and endeddatetime 2016-11-02 22:00:00.000. I want to get the difference of two dates by 2 decimal places. Anyone can help for the SSRS expression needed to perform this?
Result for the above diff is 0.67
TIA!
With number formatting set to Number with 2 decimal places, this expression gives you the same result as your SQL statement:
=Round(DateDiff(DateInterval.Second,Fields!FirstDate.Value,Fields!SecondDate.Value) /60 / 60, 0) / 24
You need to calculate the number of seconds and round this as an hour value to emulate the behaviour of SQL's DATEDIFF function as the .NET version only considers complete units when comparing dates. See this question for further details of this: SQL Server DateDiff Vs .Net DateDiff.
If you just used:
=DateDiff(DateInterval.Day,Fields!FirstDate.Value,Fields!SecondDate.Value)
then you'll get a result of 0.00 as there are no complete days between these dates, rather than the 0.65 you get from the SQL statement.
Similarly, if you try:
=DateDiff(DateInterval.Hour,Fields!FirstDate.Value,Fields!SecondDate.Value) / 24
you'll get a result of 0.63, as the number of complete hours between your dates is 15 and 15 / 24 = 0.625.
I developed a SSRS report. The output is as below
Here i have subtotal for amt, cust and Tbl. I need subtotal for Avg also.
I tried below formulas in the subtotal columns
=[Sum(total)]/[Sum(cust_count)]
and the output is as below
How can i achieve the same?
You can use this expression:
=Sum(Fields!amt.Value) / Sum(Fields!cust.Value)
Assuming that:
Sum(Fields!amt.Value) is the expression used to obtain 183.00 in you example
Sum(Fields!cust.Value) is the expression used to obtain 8.00 in you example
I have one ssrs report having matrix table which looks like this
YEAR A1 B1 Total percentage
2012 23 11 34
2013 12 12 24
2014 32 43 75
here i need to find percentage using below formula in ssrs expression
(Total of current year-Total of previous year)/(Total of previous year)*100
[for ex take 2012 - (Total for 2012-Total for 2011)/(Total for 2011)*100
The easiest way is to add a column to your data set that had the previous year total. Then you would right click the Percentage field and create an expression like the one above you want to calculate.
Expression Examples
One way easy way would be to use the Function previous, in SSRS this function returns the previous row item. Calculating the percentage would then be something like:
((Previous(Count(Fields!Day.Value))-ReportItems!Textbox22.Value) / ReportItems!Textbox22.Value )
Note: Textbox22.Value would be the base item/count you are comparing as a percentage.