Check Decimal value is Zero in RDLC - rdlc

I want to check whether a sum of decimal values equal to zero in RDLC. I tried
=IIF(SUM(Fields!JanuaryValue.Value, "GrossProfitDataSet")=0,"0.00","F")
and
=IIF(SUM(Fields!JanuaryValue.Value, "GrossProfitDataSet")=CDec("0.00"),"0.00","F")
In both expressions, the result is "F". What might be the issue?

You should try something like this:
=IIF(Sum(Fields!JanuaryValue.Value, "GrossProfitDataSet") > 0, "F", "0.00")
Instead of looking for a zero, you are looking for a value greater than what you want, eliminating the need for the correct format.
You should also change the data in the DataTable to decimal.
Here's a similar problem: RDLC report doesn't detect NULL values correctly

Related

SSRS - Number format expression not working

I have a table in my database called systemconfig which has some configs that I'll use on my reports. The idea is, instead of adjusting the 'number formats' directly in the textboxes properties of the report, I just change a value in this table, and then through a custom expression in the format property, it gets the value from this table
The query of the dataset 'ds_DecimalValues' is like this:
DECLARE #DecimalValue Nvarchar(500)
SELECT #DecimalValue =
( SELECT Value as 'DecimalValue' FROM SystemConfig WHERE Key = Decimal_Value )
SELECT
DecimalValue = #DecimalValue
ok, the result of this query is ##
In the textbox properties I have this expression in the Format line:
=First(Fields!DecimalValue.Value, "ds_DecimalValue")
But the report is showing 2 decimal values instead of none. I'm not sure if the decimal values are correct on the systemconfig table, I assume that '##' is correct to show no decimal values but I'm not sure about it. Any ideas guys??
Regards.
Would something like this work for you? Should round it to the nearest integer
=Floor(First(Fields!DecimalValue.Value, "ds_DecimalValue"))
When I have done this in the past I would typically use someting like f0 or n0 as the format code.
Try using this instead of ##.
If this does not work then a couple of things to debug.
Add a textbox that contains the same expression as you are using in your format property expression, make sure it is returning what you expect
Type the format code directly in and make sure that it formats as you expected.
remember that you don't need to use quotes when using codes like f0 etc.

Correctly convert price into a 8 digits string on ms-access

I need to convert a price into a string of 8 digits and right now, I'm using this:
=Format(Replace(Round([total],2),",",""),"00000000")
If the price is (eg: 105.55) it converts like this: 00010455 and this is ok!
The problem:
When the price ends with a zero (like this: 147.60). In this case, it returns 00001476and it's missing the last zero which I need to correctly solve the rest.
Even if I remove the Round part, I get the same problem.
=Format(Replace([total],",",""),"00000000")
I can't figure why this is happening and how to do it right...
Try this simpler approach:
=Format([total] * 100, "00000000")

How can I set a minimal amount of numbers after the decimal dot (0.9=>0.90)

I'm using google bigquery, and a column has values I want to round. If I do, and the rounded value ends in a zero, the zero is not displayed.
I've tried the function FORMAT, which apparently has some .number function, but I have no idea how to use it. Whenever I include any 2 things separated by a comma inside its brackets, it complains that it only takes 1 value.
You would use FORMAT() with the precision specifier. For four decimal places always -- including zeros:
select format('%.4f', 1.23)
If the BQ documentation does not answer your questions, I find that that the function seems to be inspired by the classic C printf()/sprintf() functions.
Unaware if in BigQuery (haven't used it ever) there is a better way I guess this will fix your problem since I just tried it in their console.
Cast your float to a string and then check if your last digit is a 0. In case it's not add it:
SELECT case when RIGHT(cast(0.9 as string), 1) <> '0' then cast(0.9 as string)+'0' else cast(0.9 as string) end as FormattedNumber

Handle divide by zero exception in this SSRS rdlc expression

The following code is showing result as Nan% if values are zero:
=FORMAT(((Sum(IIF(Fields!flag.Value=1,CINT(Fields!area1.Value),0)))
/ (Sum(IIF(Fields!flag.Value=1,CINT(Fields!UnitArea.Value),0))) *100),"N") + "%"
The simplest way to avoid the divide by zero error here is to not create it in the first place! If you replace the 0 as second return value in the divisor Iif expression with a 1, then the problem goes away.
That said I think your whole expression could do with simplifying somewhat. If I read it correctly you want to determine the proportion of area1 within UnitArea but only when the value of flag is 1. The expression could be thus written:
=Format(
Iif(
Fields!flag.Value = 1,
CInt(Fields!area1.Value) / CInt(Fields!UnitArea.Value),
Nothing
),
"Percent"
)
Note that I've dropped the multiplier and instead used the Format function to return the result of the division as a percentage (you could also simply further by removing the Format function entirely and handling the formatting in the designer).
You don't have to layout the expression with indentation as I have, but the expression builder ignores the whitespace and it does make larger expressions easier to read, so I think its a good habit to get into.

Jasper Reports sum a field conditionally based on the value of another field

In Jasper Reports, can you accumulate a variable (a double; calculation = Sum) of Field ($F{adr}, a double) based on the value of a different field ($F{hce}, a string);
I have tried
$F{hce} == "Y" ? $F{adr} : 0
I thought I had used this capability in JR b4, but I can't make it work now. It just comes up with zeros.
Yes, you are on the right lines. Check your field is in the correct band. Try dragging a numeric field into the summary band. You should get an option to aggregate as a sum. You can then edit the expression with a ternary as above and that should allow you to selectively sum stuff. The band, datatype and reset and increment type have to be correctly set in the properties.