Custom code to fix #Error showing in SSRS reports - vb.net

I have a few reports built using Report Builder 3 for MSSQL 2008 Reporting Services.
Some fields in my report are showing "#Error", instead of this I want to show only a simple "-". Is there any built-in function or custom code to overcome this?

I'd still really like to see your formula but you seem determined not to show it, so I'll take a wild stab at answering without it. I imagine that you are doing something like dividing the field on the current row by the field on the previous row. However, this would give you Infinity on the first line rather than #Error so there is something else going on. But let's run with this anyway since we don't have your formula.
The most common way to solve this is to check for Nothing being returned for the Previous function, usually indicating that you are on the first row (assuming your field always has data). This has the advantage of also working on fields that are not guaranteed to have a value.
=IIF(IsNothing(Previous(Fields!MyField.Value)), "-", Fields!MyField.Value / Previous(Fields!MyField.Value))
Here is another way you could do it using the row number, which will always check for the first row regardless:
=IIF(RowNumber(Nothing) = 1, "-", Fields!MyField.Value / Previous(Fields!MyField.Value))
This assumes that the error is being caused by the Value formula and not by some other mechanism such as applying an expression to other properties like Format, Color which is invalid when there is no previous row.

Related

SSRS Colour Fomatting across multiple columns

I've created a SSRS report to examine whether certain fields contain a specific value using a simple case, when statement with the values returned being 'Yes' or 'No'. I'd like the cells to be coloured yellow with the value is a 'Yes'. (See Sample Table).
I know I can do this using the function IIF(Fields!Result1.Value="Yes","Yellow","Transparent") but for a table with multiple columns (>60), is there a way to copy the background colour formatting without having to write the function for each column?
If you want to compare the value of each text box/cell with "YES" then you can use the ME.Value reference.
There is little documentation on ME (https://msdn.microsoft.com/en-us/library/dd255285.aspx?f=255&MSPPError=-2147217396)
=IIF(ME.Value = "Yes", "Yellow", "Transparent")
To access the value of the current text box, you can use the Visual
Basic built-in global Me.Value or simply Value. In report functions
such as First and aggregate functions, use the fully qualified syntax.
Unfortunately, ME does not seem to be fully implemented - it causes errors when used in places that were not created to use ME correctly. An ACTION (i.e. Go To URL) that uses ME will fail with an error of an unknown reference.

Set analysis formula in table does not work properly

I have a table with formulas using set analysis syntax. Like so:
((RAWP_PRICE-ONLY({1<RAWP_YEARMONTH='$(Auswahlperiode)'}>}RAWP_PRICE))*ARRO_AnteilROAR_in_%/100)
/Sum({$<ARRO_PREISPERIODE={'$(Auswahlperiode)'}>}ARRO_ArtikelRohstoffPreis_MONTH)
My problem is now, that without the 1 inside the only expression, my table will show now results just "-" signs. But with the 1, my selcetion does not play a role anymore. But this is important.
How can get this formula running without having my selection ignored. Thanks a lot.
BTW: $(Auswahlperiode) is a variable given in a inputbox.
if you want to use 1 and still not having selections ignored, depends on how many fields you have, you can use explicit selections inside the set analysis:
for example if I want not to ignore the "Month" field then in the set analysis I will add Month=$::Month - so even though I'm using 1, Month field is not ignored.

Function that searches for the exact same date or the closest one in the past + one extra condition

This is a continuation of " Is it possible to write a VBA code that searches for the exact same data or the closest one in the past? "
Basically I would like to expand the function that #Jeeped posted but for some reason it's not going as planned eventhough I'm doing the same stuff he showed.
The extra condition in this case is that the machine used to produce the juice must be equivalent to the machine of the parameters.
(the image of what I'm doing)
Basically if a juice is made on 29/09 with machine M0 for example then I want to have the parameters that were used for that juice. Obviously the parameters of 30/09 weren't used but the parameters of 25/09 for machine M0 were used.
I edited the code #Jeeped posted in my previous question to the following
=IFERROR(INDEX(C$2:C$10, MIN(INDEX(ROW($1:$10)+($A$2:$A$10>$F2)*1E+99+($B$2=$G$2),,))),"")
But I get an error and I'm not sure why but I have a feeling it has to do with what I wrote ($B$2=$G$2) but how do I fix it?
DISCLAIMER: the percentages used are fictive, it's just a function I need to get working for several Workbooks that will automate some work I need to do every month.
It looks like you want to add the condition that columns B should match G2. This should do the trick.
=IFERROR(INDEX(C$2:C$10, MIN(INDEX(ROW($1:$9)+(($A$2:$A$10>$F2)+($B$2:$B$10<>$G2))*1E+99,,))),"")
This type of formula does not make direct matches. It excludes everything that doesn't match and then accepts whatever is left over. So like the date in F2 is compared to the dates in column A and anything that is larger (i.e. later) is multiplied by a very large number. We do the same to the machine ID in G2. Anything that does not match the machines in column B get multiplied by the same very large number. By mathematically excluding anything that doesn't fit, we are left with what does fit.
It is also important to note that the ROW(1:9) is the position within C2:C10 or A2:A10, not the actual row on the worksheet.
Addendum: With the dates now unsorted, I can provide both a standard and an array formula to compensate. The array formula for I2 is,
=SUMIFS(C$2:C$10,$A$2:$A$10,MAX(IF($A$2:$A$10<=$F2,IF($B$2:$B$10=$G2,$A$2:$A$10))),$B$2:$B$10,$G2)
This must be finalized with Ctrl+Shift+Enter rather than simply Enter. Once entered correctly, it can be filled both right and down. Next is a standard formula that does not require Ctrl+Shift+Enter but accomplishes the same thing. Your results should resemble the following image.
=SUMIFS(C$2:C$10, $A$2:$A$10,MAX(INDEX(($A$2:$A$10<=$F2)*($B$2:$B$10=$G2)*($A$2:$A$10),,)),$B$2:$B$10,$G2)
    
I think the formula below might answer your question. Please see the image for reference.
Formula Used: =INDEX($D$2:$E$7,MATCH(1,($B$2:$B$7<$H3)*($C$2:$C$7=$I3),0),1)
Please note - this requires your date of parameter change to be sorted from newest to oldest.
To apply this formula, press CTRL+SHIFT+ENTER after writing the formula. This is required for excel to understand that this should function as an Array formula. On doing so, excel will automatically add the curley brackets at the beginning and end of the formula as can be seen in the image.
Only small difference for formula to get %Oranges will be replacing the last 1 by 2.
INDEX($D$2:$E$7,MATCH(1,($B$2:$B$7<$H3)*($C$2:$C$7=$I3),0),2)
Hope this answers your question. Please let me know if you need further assistance.

Netsuite - Saved Search with Days Calculation Formula

![enter image description here][1]I am trying to create a Saved Search in Netsuite that calculates the number of days between two dates in a summarized search. I am attaching a screenshot of the Results tab for reference. I have tried using a Numeric Formula field, as well as a Date/Time Formula field. I have also tried every Summary Type available. Is there another way to do this? I just get an entire blank column when I run this.
As some background, I am trying to calculate how many days between when the system note was changed to Pending Accounting to when the system note was changed to Processed.
Thanks!
Update: It won't let me upload photos. Here is the formula I am using:
(CASE WHEN {systemnotes.newvalue}
= 'Processed'THEN {systemnotes.date} END)-(CASE WHEN {systemnotes.newvalue}
='Pending Accounting'THEN {systemnotes.date} END)
I'm not sure you are going to be able to evaluate this.
systemnotes.value can only have one value at each cell, which means that you can't have it be equal to Processed and Pending Accounting at the same time.
What you do in this case is something along the lines of
CASE WHEN {systemnotes.newvalue}= 'Processed'
THEN TO_DATE({systemnotes.date})
ELSEIF {systemnotes.newvalue}='Pending Accounting'
THEN TO_DATE({systemnotes.date})*-1
ELSE 0
END
And then do a sum on the whole thing. I'm pretty sure this won't work as this is not tested, but the idea is to declare on each cell the positive, negative or null value, and then add make NS add the whole column to summarise.
Also you might find issues for duplicate values so if the state goes back to a previous state you might get weird results.
Edit- see if you can find something to work with unix time, that might make life easier.
See reference for oracle sql: http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm

Print When (last element reached) Expression in JasperReports

Is it possible to generated a "Print When Expression" that detects the last element in an XML datasource file?
Basically I have a report with a column break inserted after a sub-report in a detail band so I can clearly define new pages for the beginning of a new record. But it always leaves me with a blank last page. So I am hoping that I can prevent this if I have a print when condition that prevents the column break if it is the last record element in the XML datasource.
Is this even possible?
The problem is that you don't know it's the last element until after you look for the next element. I don't think there is a simple way.
In principle it should be fine to do something like this:
Create a super-report around the entire report. Run the same query in the super-report. Count the rows. Then pass the number of rows to the original report (which is now a subreport) and re-run the query again. Clearly, running the query twice is another drawback.
If the data source were SQL, then I would suggest modifying the SQL to return the number of rows as part of the result set. But for non-SQL data sources, you need some way of knowing the number of rows (well... some way of identifying the last row) before you reach the last row.
Many years late...
if you sure your datasource is a JRBeanCollectionDataSource, you could use:
$V{REPORT_COUNT} == ((net.sf.jasperreports.engine.data.JRBeanCollectionDataSource)ORIGINAL_DATA_SOURCE( )).getData().size()