Format number Rdlc report - reporting-services

i need to show numbers 1 2 3 in Arabic letters
i write in text box expression this statement
=FormatNumber(Fields!Size.Value,1,-2,-2,-2)
but i don't know it's parameter and which parameter can show numbers in Arabic format
MANY THANKS

set report language to your local language (ar-EG)
in the textbox properties set NumeralVariant to 3
references
similar problem
NumeralVariant
limitations
1- will not work for strings containing numbers
2- will not work for dates
work around limitation with bad performance i guess
you can replace any english number with arabic number using Replace method in any string that may contain numbers
your expression will be some thing like this
=Replace(Replace(Replace(Fields!FieldName.Value,"0","۰"),"1","۱"),"2","۲")
complete expression to 9

You can write function in code and use that
enter image description here
Public Shared Function farsi(input As String) As String
Dim result As String = input
result = result.Replace("1", "۱")
result = result.Replace("2", "۲")
result = result.Replace("3", "۳")
result = result.Replace("4", "۴")
result = result.Replace("5", "۵")
result = result.Replace("6", "۶")
result = result.Replace("7", "۷")
result = result.Replace("8", "۸")
result = result.Replace("9", "۹")
result = result.Replace("0", "۰")
Return result
End Function
Usage:
=Code.farsi(1111.555)

Public Shared Function Arabic(input As String) As String
Dim result As String = input
result = result.Replace("1", "۱")
result = result.Replace("2", "۲")
result = result.Replace("3", "۳")
result = result.Replace("4", "٤")
result = result.Replace("5", "۵")
result = result.Replace("6", "٦")
result = result.Replace("7", "۷")
result = result.Replace("8", "۸")
result = result.Replace("9", "۹")
result = result.Replace("0", "۰")
Return result
End Function
Use it for arabic Numbers
=Code.Arabic(Fields!OrderID.Value)
=Code.Arabic(FieldName)

Related

Function with for loop - How to return in vb | UFT

I would need support for that. I guess it's an easy one but i would like to get different approach if possible.
I have the following Function and i just want to return value. If possible within a string variable.
StrVal = "123 Test"
Function IsHaving(StrVal)
Set reg1 = New RegExp
reg1.Gloabl=True
reg1.IgnoreCase=False
reg1.Pattern="\d+"
Set mats = reg.Execute(StrVal)
For Each mat In mats
return mat.Value
Next
End Function
And then passing the value returned in another string
StrNum = IsHaving(StrVal)
I would like to do this way but i am not sure that in vb i can return from a loop for ( within the Function).
Some ideas on that ?

Display a column values in Report Header

need to pass one column in Lookupset and I am doing as below
="Billing Code: "+Code.JoinDistinct(LookupSet(Fields!BillingCode.Value, Fields!BillingCode.Value, Fields!BillingCode.Value, "DataSet1"),",")
and the Function is
public shared function JoinDistinct(
dups as object(),
delimiter as string
) as string
dim result as string = ""
system.array.sort(dups)
for i as integer = 0 to dups.length - 1
if i <> 0 then result += delimiter
if i = 0 orElse dups(i) <> dups(i-1) then result += dups(i)
next i
return result
end function
Result
Billing Code: ,,,A,,,,,,
How Can I remove extra commas
What you're trying to do is certainly possible, but requires a bit of a workaround. The Join function is designed to work on an array of values. The column you used, even though it may have multiple rows at that scope, is not an array. You can use the LookupSet function to get the rows as an array and pass them into the Join function. If there may be duplicate values that you want to remove, you'll have to add custom code to handle that.
Here's an example of how to do that: https://stackoverflow.com/a/27141955/2033717
Let me know if this answers your question.

How to display number values with commas in form

In my Access query, I have the query using a VBA function to figure the value that goes in the query field.
In the form, if the stringval textbox has a value, then I want to compute it, but if not, it should remain empty (null).
Function GetValue(stringval, numval)
Dim result
stringval= stringval & ""
result= IIf(stringval<> "", numval* 1.5, Null)
GetValue = Int(result)
End Function
Now, I have a form that uses this query, and on the form is a textbox that displays the query value. I want the value to be formatted with commas in the numbers for easy reading. Everything I've tried so far does not show any commas.
I've tried:
used Standard for the Format > Formatfor the textbox (in properties)
putting #,###.### in the textbox Format value
putting #,##0.0## in the textbox Format value
changing Data > Text Format but it only gives me Plain Text and Rich Text - no option for numbers.
returning a double from the function
Note: if I don't use a custom VBA function, and write the formula directly into the query, then it does display commas. But when I move the formula into the function then the commas are lost.
What do I do?
[update]
I tried Gustav's solutions and since they didn't work for me, I added those as items to my "what I've tried" list above.
Also, if I look at the query in datasheet view, the number values sort alphabetically instead of by the size of the value. When I used the forumulae directly in the query instead of using functions, it sorted by the value of the number. I hope this is a clue.
Numbers carries no format. A format is applied when displayed only.
But be sure to return a Double if not Null:
Function GetValue(stringval, numval)
Dim result
If stringval & "" <> "" Then
result = Int(CDbl(numval) * 1.5)
Else
result = Null
End If
GetValue = result
End Function
Then apply your Format to the textbox
#,##0.0##
Or force a formatted string to be returned:
If stringval & "" <> "" Then
result = Format(Int(CDbl(numval) * 1.5), "#,##0.0##")
Else
result = Null
End If
and skip formatting of the textbox.
The solution is this: the function has to be declared as a double.
That allows the query's datasheet view to know it is displaying numbers - and so you can set the field's format to Standard for the comma to display. This also allows the form to know it has a number and it will display the comma there, too. I knew it had to do with double, but didn't realize before that the function needed to be declared as such.
Function GetValue(stringval, numval) as double '<----THIS!!!!
Dim result
If stringval & "" <> "" Then
result = numval * 1.5
Else
result = 0 `<--can't return null here; use nz function in control source for textbox
End If
GetValue = int(result) 'to remove decimals
End Function
The problem I was having was in some of my functions I need to return double or null, because I wanted textboxes to remain blank if they contained no data. Now, at least I know how to make the numbers generated by functions to display commas.
And here is how to deal with the fact that you can't return null as the value of a double. The function is originally from here.
Put this function in a module so it is public, and then in the control source for the textbox, instead of just putting the field value, put Zn(fieldvalue). This works like a charm (although using functions in the control source seems to have a delay on the form display). This way you can keep the underlying value as a double and still get commas to display in both the form and the query whilst keeping the field blank if necessary.
Public Function Zn(pvar)
' Return null if input is zero or ""
If IsNull(pvar) Then
Zn = Null
ElseIf IsNumeric(pvar) Then
If pvar = 0 Then
Zn = Null
Else
Zn = pvar
End If
Else
If Len(pvar) = 0 Then
Zn = Null
Else
Zn = pvar
End If
End If
End Function

Display the non selected parameter in SSRS

In case of Multi-valued parameters,we usually use join function to display the selected values into a Text-box.But what if I wanted Show only the non selected parameters?IE If there are 10 values in the drop down list of a parameter and I selected the first 5 and wanted to display only the remaining 5 parameter instead of the first 5.What do i do?
I have created a multivalue parameter with the name Param which has had its labels and values set like so:
Label Value
====== =====
Label1 1
Label2 2
Label3 3
Label4 4
Label5 5
I then created the following code in the Report Properties --> Code menu:
'Global array objects to hold the total and selected values
Private Dim parameterList() AS string
Private Dim selectedParameters() AS string
'populates the list of all parameters using split and returns the input string
Public Function SetParameterList(nextParameter as String) AS String
parameterList = Split(nextParameter ,",")
Return nextParameter
End Function
'populates the list of selected parameters using split and returns the input string
Public Function SetSelectedParameters(delimitedParameters as String) AS String
selectedParameters = Split(delimitedParameters,",")
Return delimitedParameters
End Function
'Returns the not selected parameters
Public Function GetNotSelectedParameters() AS String
Dim notSelected As String
Dim i as Integer
Dim x as Integer
'Loop through each value in the all parameters array...
For i = 0 to parameterList.GetUpperBound(0)
'...for each one of those values check it against the selected parameters
For x = 0 to selectedParameters.GetUpperBound(0)
'Where there is a match, set the all parameters value to a string unlikely to be a genuine parameter value
IF parameterList(i) = selectedParameters(x) Then
parameterList(i) = "!*!"
End IF
Next
Next
'Join the all parameters array back into a string
notSelected = Join(parameterList, ", ")
'Remove the !*! values added earlier from the middle and the end of the string
notSelected = Replace(notSelected, "!*!, ", "")
notSelected = Replace(notSelected, ", !*!", "")
Return notSelected
End Function
To use this code I created 3 textboxes with the following expressions:
=Code.SetParameterList(Join(LookUpSet(1,1,Fields!ParamLabel.Value,"DataSet1"),","))
=Code.SetSelectedParameters(Join(Parameters!Param.Label, ","))
=Code.GetNotSelectedParameters()
Note: to hide the output of any of these textboxes, you could set the function return value to be "".
I imagine my code could be improved upon significantly, but this gets the job done and should at least point you in the right direction.
First create a multivalued parameter ("param1"), with available values ranging from 1 to 10.
Then create a query (query1), which returns the parameters from 1 to 10 filtering out the
selected values from "param1" -> where query1.col NOT IN (#param1)
Then create another multivalued parameter("param2"), set a default value (get values from a query) point to "query1" to fill in the unselected values
use a text box with the following code "=Join(Parameters!param1.Value,",")"
To make query1 you can use unions.
You will get back the values not selected,

Populating multiple values in rdlc reporting

I am using rdlc report, i have a column in database which i want to display in the report.
vehicleDamageArea=1,2,3
In the report I need to mark the placeholders with these values.
=iif((Fields!vehicleDamageArea.Value="3"),Chr(253),Chr(168)) like this.
But as we know,it will check the whole value 1,2,3="3" not the splitted values.
Any suggestion to check by splitting the vehicleDamageArea parameter.
I made it to work as below
Public Shared Function CheckValue(ByVal InString As String,ByVal input as String) As Char
Dim output As String = String.Empty
Dim Parts() As String = InString.ToString().Split(",")
For i As Integer = 0 To Parts.Length - 1
If Parts(i) = input Then
output = Chr(0120)
Exit For
Else
output = Chr(0111)
End If
Next i
Return output
End Function
You can get the individual values using the split function in reporting services. It returns a zero-based string array, so for your example you need
=Split(First(Fields!ID.Value),",")(2)
You should make a function that accept a comma separated expression, than process this string and return a Boolean, then call this function as for boolean value.