I want to convert and display 4.520 to 4520 or 5.000 to 5000 in crystal report and concatenate zz at start and end so final string should be zz4520zz or zz5000zz. I am getting number from sql and data is stored in varchar. how can I do this?
totext(tonumber({DataTable1.number}),0)
"zz" + totext(tonumber({DataTable1.number}),0,"") + "zz"
Related
I have a very simple issue in MS-Access and somehow the solution eludes me. I want to display a field that holds a percentage with or without decimals. So I want to display the decimal separator only when there is actually a decimal in the field. This illustrates the problem:
debug.? format(0.21, "0.#%"), format(0.215, "0.#%")
21,% 21,5%
How to get rid of the nasty comma in 21,%. I tired al sorts of format options. I either always get a decimal or I get the value rounded, which I do not want.
How can I display 0.21 as 21% and 0,215 as 21,5% ?
You can use IIf:
PercentValue = Format(Value, "0" & IIf(Value * 100 = Fix(Value * 100), "", ".##") & "%")
Value = 0.21 -> 21%
Value = 0.215 -> 21.5%
I am working on pentaho report designer
HereI created one cross tab report. When I preview the report it is showing me results as below
name total
A 598.00
B 273.00
c 124.00
d 0.23
e 0.23
f 0.00
g 273.00
In the above results I want only the particular values should look in decimal format
Like I want only o.23 in the above result look like in decimal format and all the other I want to look like integer with out any decimal portions.
Is there any expression I can write.
Thanks in advance
In Pentaho report designer, you must define a data type for your inputs(https://www.screencast.com/t/y440gotpnp). The case that you describe could be treated with a formula(check the floating numbers e.g. different to "00" ... ) and as an output data type you could use a string(text)
Maybe you should use Truncate function inside you query, something like truncate(total,2), this will keep 2 digits after the ',' and if your totals end with 00 they won't be shown automatically.
I am developing a pig script and have to display the number as 6 digits eventhough the number is 4 digit.
ex: 6001 should be displayed as 006001.
Thank you.
Alternatively, you can cast it to string and append '00'.
y = foreach x generate CONCAT('00',(chararray)val1);
I have the following expression in one of my textbox in my SSRS Report:
=IIF(IsNothing(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!AgregarVentas.Value, Fields!venta_prom_sem.Value, "EfectividadDeFrecuencias_Ventas")) = True
,"0"
,IIF(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!Agregar.Value, Fields!total_cant_pos.Value, "EfectividadDeFrecuencias_Total") <> "0"
,FormatNumber(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!AgregarVentas.Value, Fields!venta_frecuencia.Value, "EfectividadDeFrecuencias_Ventas")
/ Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!Agregar.Value, Fields!total_cant_pos.Value, "EfectividadDeFrecuencias_Total"),2)
,"0"))
That division will give me an int64 number, 15 digits (If such math operation gives that amount of decimal digits).
So the results are:
Now here is the tricky part:
My code behind that grabs the Dataset does a round and converts to decimal and then shows to a Crystal Report.
dr.venta_prom_sem = (Convert.ToDouble(dr.total_cant_pos) != 0 ? (Math.Round((Convert.ToDouble(dr.venta_frecuencia) / Convert.ToDouble(dr.total_cant_pos)), 2)).ToString() : "0");
So this will give me:
as you can see if I use a format Number the 1.3 will convert to 1,30 and that will be wrong, same as 1 (1,00). Now 1,339...etc will give me 1,34 and that is fine.
But check the 1.065, with FormatNumber that will give me 1.07 instead of 1.06.
So the thing is, how can I format my numbers to be the last non zero digit after the decimal point AND select the lower value if the (in this case) 3rd value is 5, instead of 1.07 be 1.06. I think If I use Ceiling or Floor it gives me the integer part.
Try this:
=ROUND(1.339,2,MidpointRounding.ToEven)
This gives: 1.34
And
=ROUND(1.065,2,MidpointRounding.ToEven)
Gives: 1.06
Let me know if this was helpful.
I am writing some code in Visual Basic.net and have a question.
If I have a long number, that is larger than 1000, how can I format this value to be 1,000 (with a comma) and for this to be stored in a string?
For e.g.
1234 will be stored as 1,234
12345 will be stored as 12,345
123456 will be stored as 123,456
Is this done with a TryParse statement?
May I have some help to so this?
Take a look at The Numeric ("N") Format Specifier
General use:
Dim dblValue As Double = -12445.6789
Console.WriteLine(dblValue.ToString("N", CultureInfo.InvariantCulture))
' Displays -12,445.68
If you are only using integers then the following:
Dim numberString As String = 1234.ToString("N0")
Will show numberString = "1,234" as the "N0" format will not add any figures after a decimal point.
For those wanting to do a currency with commas and decimals use the following: .ToString("$0,00.00")
Using $ notation:
int myvar = 12345;
Console.WriteLine($"Here is my number: {myvar:N0}");