numbers/decimals not sorting in radgrid - vb.net

Hi I am not able to sort a column that contains decimals in a radgrid. When I sort, it only sorts by first number, like if sorting a string.
Ex: 1000, 12, 1300, 2189, 20
Instead of sorting like this:
12, 20, 1000, 1300, 2189
I am using EF4 and working with VS2012 in vb.net.
Any suggestions? this is my column:

Related

Code to obtain the maximum value out of a list and the three consecutive values after the maximum value

I am writing a model to calculate the maximum production capacity for a machine in a year based on 15-min data. As the maximum capacity is not the sum of the required capacity for all 15-min over the year, I want to write a piece of code that determines the maximum value in the list and then adds this maximum value and the three next consecutive values after this maximum value to a new variable. An simplified example would be:
fifteen_min_capacity = [10, 12, 3, 4, 8, 12, 10, 9, 2, 10, 4, 3, 15, 8, 9, 3, 4, 10]
The piece of code I want to write would be able to determine the maximum capacity in this list (15) and then add this capacity plus the three consecutive ones (8,9,3) to a new variables:
hourly_capacity = 35
Does anyone now the code that would give this output?
I have tried using the max(), the sum() and a combination of both. However, I do not get a working code. Any help would be much appreciated!

Postgis: How do I select every second point from LINESTRING?

In DBeaver I have a table containing some GPS coordinates stored as Postgis LINESTRING format.
My questions is: If I have, say, this info:
LINESTRING(20 20, 30 30, 40 40, 50 50, 60 60, 70 70)
which built-in ST function can I use to get every N-th element in that LINESTRING? For example, if I choose 2, I would get:
LINESTRING(20 20, 40 40, 60 60)
, if 3:
LINESTRING(20 20, 50 50)
and so on.
I've tried with ST_SIMPLIFY and ST_POINTN, but that's now exactly what I need because I still want it to stay a LINESTRING but just with less points (lower resolution).
Any ideas?
Thanks :-)
Welcome to SO. Have you tried using ST_DumpPoints and applying a module % over the vertices path? e.g. every second record:
WITH j AS (
SELECT
ST_DumpPoints('LINESTRING(20 20, 30 30, 40 40, 50 50, 60 60, 70 70)') AS point
)
SELECT ST_AsText(ST_MakeLine((point).geom)) FROM j
WHERE (point).path[1] % 2 = 0;
st_astext
-------------------------------
LINESTRING(30 30,50 50,70 70)
(1 Zeile)
Further reading:
ST_MakeLine
CTE
ST_Simplify should return a linestring unless the simplification results in an invalid geometry for a lingstring, e.i., less than 2 vertex. If you always want to return a linestring consider ST_SimplifyPreserveTopology . It ensures that at least two vertices are returned in a linestring.
https://postgis.net/docs/ST_SimplifyPreserveTopology.html

How to floor a number in sql based on a range

I would like to know if there is a function or some sort of way to round a number to lowest whole value. Something like floor, but to a specified increment like 10. So for example:
0.766,5.0883, 9, 9.9999 would all be floored to 0
11.84848, 15.84763, 19.999 would all be floored to 10
etc...
I'm basically looking to fit numbers in the ranges of 0, 10, 20, 30, etc
Can I also do it with different ranges? For example 0, 100, 200, 300, etc
Thank you.
You can do this with arithmetic and floor():
select 10*floor(val / 10)
You can replace the 10s with whatever value you want.

ruby sorting a multidimensional array of mixed classes by last value, a string

So I grab a bunch of information from a few databases to get an array of values, their names and order being:
['type', 'baseid', 'lotid', 'split', 'sub', 'sequence', 'resourceid', 'user1', 'user2', 'part', 'department']
So I have an array of those, which I put into a tableview and I need to resort the array by the department value without changing any of the order of the internal array, so that in the table all assemblies are together, all GMBEAD BLASTs are together ect...
An example of the array with values looks like:
[[EDM, M, 887013393, C, 0, 2, 50, GE_1_INS], [QUALITY, M, 887013393, C, 0, 2, 60, GMDEBURR], [FINISH, M, 887013393, C, 0, 2, 70, GMBEAD BLAST]]
Yes I have tried a few .sort or .sort_by methods but with the numbers in the array it wont let me even run the program when I put in a sorting method.
What do you mean by "it wont let me even run the program"? Assuming the department is always the last column, a simple my_array.sort{ |a,b| a.last <=> b.last } should do the trick.
You want something like this:
sorted_array = your_array.sort_by {|inner_array| inner_array.last }
The errors you're getting make it sound like you're trying to sort the inner arrays, which won't work.

rdlc (piechart) customized colors for different segments

I have written a code like below, my problem was sometimes I am getting same color for different segments in the piechart if the value came from the same range.
ref:
rdlc expression iif use?
my code sample
=SWITCH(Fields!ID__Share_of_Costs.Value <= 0.99, "Yellow",
Fields!ID__Share_of_Costs.Value <= 30, "Teal",
Fields!ID__Share_of_Costs.Value <= 60, "SteelBlue",
Fields!ID__Share_of_Costs.Value <= 100, "Crimson",
)
for eg: suppose my chart value is dynamic and it will come like 22 and 29, in this case the segment will show the same color (<= 30, "Teal",) as it is difficult to differntiate. Is there is any way to give different colors for each segment like no repeated color ?
Thanks in advance...cheers
It depends what do you mean by segment (range of values or particular value) or in other words is number of your segments limited?
If yes, then you could set up as much segments as you want with particular color.
If no, then write a custom function which will return hex value as your color.