CRM Report Miscalculating columns - reporting-services

I have created a custom column, in a CRM report, and the column sometimes does not calculate the answer correctly.
See Attached image: http://imgur.com/hfHWg19
The left column is: =CDbl(Sum(Fields!ask_totalduration.Value/60)).ToString("N1", Microsoft.Crm.Reporting.RdlHelper.ReportCultureInfo.GetCultureInfo(Parameters))
The Middle column is: =Fields!ask_response.Value
The right column is: =iif(Fields!ask_response.Value>Fields!ask_totalduration.Value, "Time Met", "Time not Met")
As seen in the picture, something is not working properly, but I am unable to figure it out.
Thanks Joe

Looks like it might be a type coercion issue.
Try changing your formula to this:
=IIf(CDbl(Fields!ask_response.Value) > CDbl(Fields!ask_totalduration.Value), "Time Met", "Time not Met")
This will ensure no implicit conversions are being performed.

If you want to keep it simple you can use below formula since you have only 2 decimal points.
iif(Fields!ask_response.Value *100 >Fields!ask_totalduration.Value *100, "Time Met", "Time not Met")

Related

Ms Access - Data type mismatch error when doing sum of few columns that will contain text symbols

I'm working on a simple RDBMS project. My database contains work hours per day of each employee. I have to calculate work hours of complete month. It is not a problem. But I have a problem, here it goes, each workday field contains either number of work hours or it may contain text such as if the employee was absent (symbol "A") for a particular day or it may contain symbol ("H") for holiday etc. Now my task is to calculate the 30 day work hours and exclude any symbol. But obviously the approach I am using will get me "Data Type Mismatch Error." So any body got any solution or any suggestion please. Thanks in advance!
I tried to use sum formula with NZ function, it doesn't work. Also tried Query with the same error.
Use Val:
TrueHours: Val(Nz([YourHourTextFieldName]))
That will return 0 (zero) for non-numeric entries, and that allows you to sum the values.

SSRS AVG function with where clause

I have a question about the avg-function in SSRS/Report Builder. What I want to achieve is a expression which is giving a average of the lead time per incident which is taking the urgency of the incident in account. I already made this simple expression for all the incidents which works fine: =Avg(Fields!Lead_time_call__in_days_.Value, "DataSet1")
This is the expression I made which should take the urgency in account (but which doesn't work): =AVG(IIF(Fields!Urgency.Value = "Low", Fields!Lead_time_call__in_days_.Value, 0), "DataSet1")
This displays this: screenshot
But that's not possible, since the individual averages can't be all lower than the total average (which is correct)
Does anybody know what I'm doing wrong? Thanks!
I fixed it! Thanks to #xcvd for helping. I just had to replace the 0 with nothing. That acts as a NULL and doesn't messes up the calculation.

Srss Report #error

I am trying to get a column in a report, and I am having the issue where the report will show #error in the column. I think I have found the cause, but I am unsure, and I'm also unsure how to solve it.
The code I am currently using is:
=iif(SUM(Fields!ask_response.Value)>SUM(Fields!ask_totalduration.Value), "Time Met", "Time not Met")
Some of the values have 0 in the one of the 2 columns involved. Is there a way to get it to say "Time Not Met" if the value is 0?
Thanks
Joe
Nested IIf's are a true pain and I have had similar issues before. Copy this to a new location and start over, working your way from the inside out, testing at each level to make sure you do not get an error.
I am not sure you should be using sum in this instance.
I am not sure if this will work but I have...
=iif(IIf(IsNothing(Fields!ask_response.Value),0,Fields!ask_response.Value) > IIf(IsNothing(Fields!ask_totalduration.Value),0,Fields!ask_totalduration.V‌​alue),"Time Met", "Time not Met" )

MS Access get specific field of a record

I'm really new to MS Access and got stuck a little problem which looks like i can't solve it.
Following I have a little example which makes it easier to explain.
As you can see I have a little calendar. Very easy and simple. I do a lookup on my tblCalendarMonths and on my tblCalendarYears. The field calDisplay is a calculated field an should put the Month and the Year together. In 'Picture 2' you can see how I tried it. In 'Picture 1' you can see what happens.
All I get is are the IDs of the selected Month and Year. What do I need to do,
to see under Display: "June 2014"
Thanks in advance!
Is there a reason you want to have the date separated like that in your table? If not you can use the DatePart Function to return the year and month as you desire.
DatePart("yyyy", [CalDate]) & " " & MonthName(DatePart("m", [CalDate]))

SSRS: Summing TimeSpan values in a report

I have a report and a datasource where one of the columns are of type TimeSpan. The TimeSpan value appears to display correctly in the report when I use Fields!TheTime.Value, no problem there.
07:02:00
05:41:00
But I would like to do a Sum on those values to get the total time of a group. In C# and such I can of course do a TimeSpan + another TimeSpan, so I know they can be added. I tried
=Sum(Fields!TheTime.Value)
But it ends up printing out as a long number of some sort. For example for the outputted times above, I would get 457800000000 as the sum. And what is that even supposed to be?
Anyways, how can I sum timespan values in a report? For the above timespans I would like to end up with 12:43:00 as the sum. Unless my head failed me at math once again... but you get the idea :p
sigh The solution annoyingly simple... Why couldn't I just have tried that in the first place? Oh well... maybe because I didn't realise I had access to TimeSpan class... maybe because I had thought myself blind... But anyways, here it is:
=TimeSpan.FromTicks(Sum(Fields!TheTime.Value))
D'oh!
#Svish - I deleted my previous post because I had a fit uncertainty about my answer but I concur with #pfunk.
I finally got SSRS back up and had a play around and it certainly looks like your big number is the number of ticks so it looks like a bit of formatting of the result will work for you.
Interestingly enough my previous convoluted answer was a workaround for summing DateTime values (using SQL Server DATETIME datatype in my query) which you cannot do in SSRS (and SQL) because you cant sum a DATETIME. I'll include it here again for future reference but I think was on a bit of a tangent earlier :)
The below code converts a DateTime field into a double, sums the result and then converts it back to DateTime and formats it for hh:mm:ss
=Date.FromOADate(Sum(Fields!TheTime.Value.ToOADate())).ToString("hh:mm:ss")
What is probably happening is that when you display Fields!TheTime.Value, SSRS is smart enough to know to display that as a DateTime type field
when you add the sum in there it thinks it is a numeric type field and displays it as such (ie, it is summing the number of "ticks" in each timespan field)
try specifically formatting the summed value as a datetime in the field properties and it will probably show correctly