SSRS - Sort by number part of string - sorting

I have an SSRS report that will be used in Dynamics 365 so I can't use SQL in the dataset to help here.
I have a product/version code column that is string mixing letters and numbers. For example:
FF8,
FF9,
FF10,
FFA
These are going in to a column header and form a column group which is also sorted by the code. The standard alphabetical sorting is giving this order:
FF10 - FF8 - FF9 - FFA
I'm happy to use a substring in my sort expression to remove a preceding product code but I would like the numbers in ascending numerical format followed by text versions alphabetically:
FF8 - FF9 - FF10 - FFA

I would add a calculated column to your dataset that strips the non-numeric characters and converts to a number. This would make it easier to sort
A formula like this might help
=System.Text.RegularExpressions.Regex.Replace(Fields!productcode.Value, "[^0-9]", "")
The ^ symbol means "not" so this Regex expression will remove all characters that are not in the range of 0 to 9 (i.e. all non-numeric characters)
According to this, Regex.Replace should be supported in CRM's sandboxed reports

You also could use expression like below in Sort
=switch(Fields!name.Value="FF10",3,Fields!name.Value="FF9",2,Fields!name.Value="FF8",1,Fields!name.Value="FFA",4)
Zoe

Related

Google spreadsheets in-cell string length validation

I have a column where I want to write down numbers, but the numbers are long, 25 characters, and I could miss type it so at least knowing that I have typed the correct amount of characters would be helpful.
When typing in Google spreadsheets, I can validate the answer of a column within another column by using: '=IF(LEN(B1)=25,B1,"wrong number of digits")'
which means it would return the cell value if has 25 characters, but if its any other amount it will say wrong number, yet I need to use another column...
Is there any way that while I am typing in a cell it would let me proceed if right number of characters or give an error if I have wrong number of characters, in the same column?
UNTESTED
Please try a Data, Validation..., rule of:
=and(B1>999999999999999,len(B1)=25)

Oracle BI (OBIEE) - Wildcard search for numeric values only

I need to set up a query that returns only the values that would match a pattern {Any character & digit}
I've tried setting up a filter criteria to ' %_
[0-9] but it doesn't work...I want to exclude any results that have two letters as the first two characters of a value.
Thanks!
In the presentation column, you can use the OBIEE - Evaluate - Embedded DB Functions in a formula.
For example (not the exact regex you are looking for but you get the point):
This link contains the same image/example I uploaded, as well as a few others: http://gerardnico.com/wiki/dat/obiee/regexp_evaluate

Split a Value in a Column with Right Function in SSIS

I need an urgent help from you guys, the thing i have a column which represent the full name of a user , now i want to split it into first and last name.
The format of the Full name is "World, hello", now the first name here is hello and last name is world.
I am using Derived Column(SSIS) and using Right Function for First Name and substring function for last name, but the result of these seems to be blank, this where even i am blank. :)
It's working for me. In general, you should provide more detail in your questions on places such as this to help others recreate and troubleshoot your issue. You did not specify whether we needed to address NULLs in this field nor do I know how you'd want to interpret it so there is room for improvement on this answer.
I started with a simple OLE DB Source and hard coded a query of "SELECT 'World, Hello' AS Name".
I created 2 Derived Column Tasks. The first one adds a column to Data Flow called FirstCommaPosition. The formula I used is FINDSTRING(Name,",", 1) If NAME is NULLable, then we will need to test for nullability prior to calling the FINDSTRING function. You'll then need to determine how you will want to store the split data in the case of NULLs. I would assume both first and last are should be NULLed but I don't know that.
There are two reasons for doing this in separate steps. The first is performance. As counter-intuitive as it sounds, doing less in a derived column results in better performance because the SSIS engine can better parallelize the operations. The other is more simple - I will need to use this value to make the first and last name split so it will be easier and less maintenance to reference a column than to copy paste a formula.
The second Derived Column is going to actually perform the split.
My FirstNameUnicode column uses this formula (FirstCommaPosition > 0) ? RTRIM(LTRIM(RIGHT(Name,FirstCommaPosition))) : "" That says "If we found a comma in the preceding step, then slice out everything from the comma's position to the end of the string and apply trim operations. If we didn't find a comma, then just return a blank string. The default string type for expressions will be the Unicode (DT_WSTR) so if that is not your need, you will need to cast the resultant into the correct string codepage (DT_STR)
My LastNameUnicode column uses this formula (FirstCommaPosition > 0) ? SUBSTRING(Name,1,FirstCommaPosition -1) : "" Similar logic as above except now I use the SUBSTRING operation instead of RIGHT. Users of the 2012 release of SSIS and beyond, rejoice fo you can use the LEFT function instead of SUBSTRING. Also note that you will need to back off 1 position to remove the comma.

iReport java.lang.Float hide decimals if zero

From IBM iSeries DB2 I recieve a ordered quantity DEC 11,4.
In iReport I use java.lang.Float to print the value. Also I have a pattern #,##0.0000;-#,##0.0000 (4 Decmimal places, 1000 separator).
When something is ordered in Metric Tons, this is no problem, but when something is ordered in pieces, it also prints "2,0000". This is confusing, how do I hide the ",0000"?
You can use two fields (Text Field, for example) for showing value. You can set visibility for fields (with help of "Print when expression" property) - show one field with #,##0.0000 pattern (for metric tons) and hide another with #,##0 pattern (for pieces).
Expression can check parameter or field, for example:
$F{valueUnit}.equalsIgnoreCase("metricTon")

Sort strings numbers, like integer numbers in JQGrid

I had a jqgrid with float numbers. I tried to get rid of the right side 0 and group the numbers, so those are now like (for example: "123,242"), and you know that the type of them are now String.
I want to sort theme like integer numbers in jqgrid.
what should I do?
for example a part of a column
after sort(asc) these strings are like
this:
1,959
1,965
1,989
10,235
100
100
...
Thanks in advance.
I believe you implemented the indexing and sorting according to jqGrid document. For example: http://www.trirand.net/forum/default.aspx?g=posts&t=254
I assume you retrieved data from database. If you’ve followed those already, moreover, you may need to CAST or CONVERT that particular database field from STRING or VARCHAR into INT or NUMERIC when you bind your SQL query.
jqGrid is powerful to do rest of things automatically.
You can zero-pad them (e.g. 00100 and 01959), sort them, and then remove the padding. Computer Programming 0101.

Resources