Link to home
Start Free TrialLog in
Avatar of chrisryhal
chrisryhal

asked on

SSRS Expression Help

Could anyone help me figure out how to perform these expressions in SSRS?  They were originally in Crystal Syntax:

truncate({CHECKMAST.CHECKAMT});
replicatestring("0", 8 - length(totext(dollars, 0, "", "")));
Avatar of jgv
jgv

For the truncate: Math.Truncate(Fields!ANumberField.Value)
To replicate a character: Strings.StrDup(8, "0")

Not entirely sure how to convert the second line fully. It would help to see an example of what the value would look like before and after in crystal
Avatar of Mike McCracken
Thanks mlmcc. The questions are related but there are some differences. Stepping out on a limb (and not being entirely sure of the output of the "totext" function) the SSRS translation would be:
=Strings.StrDup(8 - Math.Truncate(Fields!CHECKAMT.Value).ToString.Length, "0")

chrisryhal, if this is not what you are looking for you will need to follow up. Again, it's helpful to see what the value would be before and after.
As used the ToText function converts the dollar figure to text with 0 decimal places and no thousand separator.

Check the VB CStr or ToText function.

mlmcc
Based on your explanation my last example should work then. I'm aware of the CStr function in VB but I haven't seen "ToText" in VB or .NET (just looked). Perhaps in a library/assembly that has to be loaded first?
ToText is prpobabl;y the Crystal functiion for CStr.

mlmcc
Avatar of chrisryhal

ASKER

Below is the entire Crystal Syntax.  I seem to be OK until it gets to the "dollarfill" in the expression which is what I don't understand how to do in SSRS.




stringvar transaction;
stringvar action;
 
stringvar acctnumfill := replicatestring("0", 10 - length({CHECKMAST.BANKACCTNUM}));
stringvar checknumfill := replicatestring("0", 10 - length(totext({CHECKMAST.CHECKNUM}, 0, "", "")));
numbervar dollars := truncate({CHECKMAST.CHECKAMT});
numbervar cents := truncate((remainder({CHECKMAST.CHECKAMT},1) * 100),2);
stringvar dollarfill := replicatestring("0", 8 - length(totext(dollars, 0, "", "")));
stringvar centfill := replicatestring("0", 2 - length(totext(cents, 0, "", "")));
 
 
 
"876" + acctnumfill + {CHECKMAST.BANKACCTNUM} + " " + transaction + action + 
" " + checknumfill + totext({CHECKMAST.CHECKNUM}, 0, "", "") + 
dollarfill + totext(dollars, 0, "") + centfill + totext(cents, 0, "") +
totext({CHECKMAST.CHECKDATE}, "MMddyy") +
"                                  "

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jgv
jgv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
jgv:   StrDup is an unrecognized identifier
jgv:   nevermind, I got it.  

StrDup(8 - Math.Truncate(Fields!CHECKAMT.Value).ToString.Length, "0")

Appears to of worked!!!

THANK YOU THANK YOU