How to format postal code in SSRS Expression Builder - reporting-services

I am trying to format a 9 digit postal code ##### - ####, This is what i have at the moment, but it does not work.
IIf(Len(First(Fields!PostalCode.Value, "VesselCreditMemo"))>5,
Format(First(Fields!PostalCode.Value, "VesselCreditMemo"),
"00000-0000"),First(Fields!PostalCode.Value, "VesselCreditMemo")
Any help would be greatly appreciated

You can just use
=mid(Fields!PostalCode.Value,1,5) &"-"& mid(Fields!PostalCode.Value,6,4)
In textbox expression.

Well, depending on your data, you should modify regular expression, but usually it's done with something like this:
=System.Text.RegularExpressions.Regex.Replace(Fields!F1.Value, "(\d{5})(\d{4})", "$1-$2")

Related

NetSuite : ADV PDF Template toFixed

Does anyone here knows how to have to decimal places in html code?
<#assign unitprice = item.itemunitprice/>
<td border-bottom="0" border-right="1" border-top="1" align="right">${unitprice}</td>
There times that the returning value is whole number {10,000} or with one (1) decimal place {10,000.8}.
Is there a way that the displaying value would become {10,000.00} or {10,000.80}.
Hope you can help me! Thanks in advance!!
Try this.
${unitprice?string.currency}
I also use ?string.currency. Also, to access price of a sales order I usually use item.amount, not sure if that would change anything.

Replace Zero with Blank in SSRS

Is it possible to replace 0 with blank in ssrs matrix. The expression
=IIF(IsNothing(Count(Fields!referralNo.Value)),0,Count(Fields!referralNo.Value))
is same as
=Count(Fields!referralNo.Value).
When I try =IIF(IsNothing(Count(Fields!referralNo.Value)),'',Count(Fields!referralNo.Value)) I'm getting error. Can somebody pls help!
you could use text box properties and set show zero as: option to blank.
I use this expression for percentage data - I like code better than format, but they both work ;)
=iif(Fields!STUFF_PCT.Value>0,Fields!STUFF_PCT.Value,"")
Use this format #,##0.00;-#,##0.00;""

how to solve SSRS Formatting issue?

Currently the data in field is coming like this 9646.88 and my requirement is
Remove decimal places and add comma for thousands e.g. 9,646
=IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value)
Please help, I am a newbie in SSRS.
Go to Properties pane when you select the textbox.
Then put this on Format property
#,0;(#,0)
Using Common Functions such as Text and Conversion functions shown in Expression window will give you the desired result.
For e.g,
Format(Int(9646.88), "#,###") // try "#,##0" which returns 0 if less than 1
where Int(9646.88) returns the integer portion of the number 9646 and Format(9646,"#,###") returns a string formatted according to instructions contained in a format String expression "#,###" which is a thousand seperator. Thus, it will give you "9,646".
So, in your case, try this,
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT", "", Format(Int(Fields!BASE_RENT_PM.Value),"#,###"))
Note:
Format(9646.88, "#,###") will return a rounded result 9,647 and
Format("VACANT", "#,###") returns just "#,###",
none of which may not be your desired result.
Have your Tried this?
=FORMAT(IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value),"#,###")
Should solve your issue.
Kind Regards
To add comma for thousands, you need to change your expression.
If you need output as 9,646 then try below.
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(Convert.ToInt32(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
OR
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(CInt(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
Updated Answer:
As you want to handle null values as well I would suggest below way to achieve your goal.
Set Textbox visibility with below expression.
=IIF(ISNOTHING(Fields!BA‌​‌​‌​SE_RENT_PM.Value),True,False)
So if null value is there then it will show blank in the ssrs report.

add decimal places to number in a report

I have a number in a table like so 153695029, I need to format it to 1,536,950.29. I have used the ~format and decimal~ spot for textbox and I get 153,695,029.00. What am I doing wrong? The datatype is a double.
You could set the Format of the TextBox control, to do this. Something like,
? Format(153695029, "###,###,###,###,###.00")
153,695,029.00

SSRS custom number format

I am go to generate an excel file from SSRS, and
I want to format the number like this...
15 is displayed as 15
14.3453453 is displayed as 14.35
12.1 is displayed as 12.1
0 is displayed as 0
1 is displayed as 1
I can apply this in Excel but unable to apply in SSRS
[=0]0;[=1]1;0.##
Does anyone can suggest another way for me? Thanks!
am assuming that you want to know how to format numbers in SSRS
Just right click the TextBox on which you want to apply formatting, go to its expression.
suppose its expression is something like below
=Fields!myField.Value
then do this
=Format(Fields!myField.Value,"##.##")
or
=Format(Fields!myFields.Value,"00.00")
difference between the two is that former one would make 4 as 4 and later one would make 4 as 04.00
this should give you an idea.
also: you might have to convert your field into a numerical one. i.e.
=Format(CDbl(Fields!myFields.Value),"00.00")
so: 0 in format expression means, when no number is present, place a 0 there and # means when no number is present, leave it. Both of them works same when numbers are present
ie. 45.6567 would be 45.65 for both of them:
UPDATE :
if you want to apply variable formatting on the same column based on row values i.e.
you want myField to have no formatting when it has no decimal value but formatting with double precision when it has decimal then you can do it through logic. (though you should not be doing so)
Go to the appropriate textbox and go to its expression and do this:
=IIF((Fields!myField.Value - CInt(Fields!myField.Value)) > 0,
Format(Fields!myField.Value, "##.##"),Fields!myField.Value)
so basically you are using IIF(condition, true,false) operator of SSRS,
ur condition is to check whether the number has decimal value, if it has, you apply the formatting and if no, you let it as it is.
this should give you an idea, how to handle variable formatting.
Have you tried with the custom format "#,##0.##" ?
You can use
=Format(Fields!myField.Value,"F2")