How to get DataGridView column of signed numeric values to sort correctly? - c#-4.0

How may I get a DataGridView column of signed numeric values to sort by signed value? Currently ColumnType is DataGridViewTextBoxColumn and ValueType is typeof(System.Single), but sorting is on the absolute rather than signed value, e.g:
-2.728
3.835
4.132
-4.511

Ignore what ValueType and column type are.
What is the type of the actual objects in the cells (dataGrid[x, y].Value.GetType())? You are probably filling the grid with System.String objects. If you fill the grid with System.Single objects they will be sorted properly.
Another option is to handle the SortCompare event.

Related

many 00000 zeros after number message Approvals Share point list Power Automate

column listWhy data from the List Share Point is displayed with many zeros. The data format in the column in the list with which I take data has these parameters:
The data type returned from this formula is Number (1, 1.0, 100).
The type of information in this column is Calculated (calculation based on other columns)
I add screenshot
I want to display "13" not "13.000000000000"
flow
floow
You could use an int function to convert the string into a number.
Let's assume you are retrieving the list item with a Get Item action and the column is named Leave Days. In that scenario you could use an expression like below:
int(outputs('Get_item')?['body/Leave_x0020_Days'])

DAX calculate an average of a column when taking cells that contain only numbers

Using PowerPivot functionality to create measures.
There are two types of values in a column: integers and NULL (string).
Trying to figure out how to create a DAX formula to calculate an average for the column that would take only cells that contain integers.
It feels that the next basic formula would work:
=CALCULATE (
AVERAGE ( tData[columnA]),
FILTER ( tData, [columnA] <> "NULL" )
)
but it throws an error: The function AVERAGE takes an argument that evaluates to numbers or dates and cannot work with values of type String.
I'm wondering if there is a way to avoid this error without removing/cleaning NULLs values beforehand?
Power BI tables cannot contain mixed types of values in a single column. If there is numbers and texts in a column, the column type is text. Numeric values included in the column is not actually numbers, they are just texts composed of numeric characters.
So, in order to make it work, you need to explicitly convert numeric strings to real numbers.
= CALCULATE(
AVERAGEX( tData[columnA], VALUE(tData[columnA]) ),
tData[columnA] <> "NULL"
)
However, I suggest not to have text and numeric values in one column. Use Power Query to either remove rows with "NULL", or convert them to BLANK.
Best way here would if you replace your NULL (string) values with the database null (nothing) value. This way your rows stay null but your calculation still works.
Go to Edit Queries > Transform > Repalce Values and replace your string NULL to a database null. Your table will look like this then:
Now the avarage calcualtion is simple:
Database null values get ignored from every calculations. This is way it works.

Supress Exponentials for text column pandas

I am reading a csv through pd.read_csv(''), column 'item_code' has values like 123AB45CD, 456DF09, but some values are interpreted as '4E+66', '6.00E+21', how can this be treated as a normal code instead of exponential.
note: All the solutions i find over here are for float/integer columns, but the column in use 'item_code' is in string format or and Object type.
Any suggestion on how to avoid or treat this exponential for column having string values stored, as i would like to see an actual code instead of E+

Auto Increment id in sharepoint

I want Auto Increment ID in SharePoint and ID should be in the form of CZAR1001,CZAR1002,CZAR1003 and so on.
I have tried =RIGHT(EmpID-LEN(EmpID-4)) this formula but its not giving proper output. Might be due to EmpID is single line text type
How to achieve an auto-incrementing field in SharePoint
The only auto-incrementing number field in SharePoint is the built-in ID field on every list.
You cannot reliably use the ID field in calculated column formulas to produce your own automatically incrementing field; a formula that references the ID field will only recalculate when you edit the calculated column.
As a workaround, you can set up a workflow to copy the ID field value to another field, such as a single line of text field, then create your formula based on that field.
How to use a calculated column to format information from a text field
You didn't say so explicitly, but I'm assuming that the EmpID field in your formula is a text field at the receiving end of a workflow process as detailed above, so that it has a text value based on the ID value.
To concatenate a number value with a text value, you can use an ampersand & character in your formula.
For example, if your EmpID value is 1001 want your calculated column output to be CZAR1001, your formula would look like this: ="CZAR"&EmpId
You cannot use the item ID for what you are trying to do. The reason is that the item ID is generated after the list item is created.
You can create a workflow that does this for you. I've been using this reliably to generate RMA numbers for months now.
Create a list ("Unique Number") and within that list create 2 columns:
lastNumber (Number Type)
nextNumber (Calculated) Formula: =lastNumber+1
Create an item in this list (EmpID) and assign any value to lastNumber.
On the list that you want the number to be generated, create a the column (Employee ID)that will hold your unique number.(Single line of text)
Fire up SharePoint Designer:
Create a variable (vNumber) type integer
Set your variable to equal nextNumber in the Unique Number list
Then "set Employee ID" to Variable "vNumber"
Then Update item in list "Unique Number" | column "lastNumber list to equal "vNumber"
This sort of creates a loop that uses the number in nextNumber assigns it to your column then shifts nextNumber to lastNumber and the calculated columns generates our next one.
You can use another calculated column to add the CZAR at the beginning if your Employee ID.
If this is confusing let me know. I'm not very good at explaining things.
Use the title column to do this, not the ID.
In your workflow create a workflow variable type Integer. Then, add an action to calculate value using ID + 1000 and insert value into your variable.
Then, add action to concatenate Text + variable into Title field.

Return the index of the last column with a specific name in excel

I'm trying to create an excel register that counts the number of times someone has registered, and returns the date of the last time they turned up but am having trouble with this last step:
See this simplified setup:
To do this, I assume I need to find the index value of the column in which the name last appears, and the use it to return the date in the first row, the tricky part trying to get that index value.
I've tried to use lookup formulas and am pretty sure that an array formula is how this can be accomplished but am unsure how I can use them in this specific case.
Assuming you have Excel 2010 or later:
=INDEX($1:$1,AGGREGATE(14,6,COLUMN(A$2:D$8)/(A$2:D$8=O2),1))
Copy down as required.
The explanation is as follows:
The portion:
(A$2:D$8=O2)
simply returns an array of Boolean TRUE/FALSE values as to whether each of the cells within that range is equal to the entry in O2 or not, i.e. using your example:
{TRUE,FALSE,TRUE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,TRUE,FALSE,FALSE;FALSE,FALSE,FALSE,TRUE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE}
The part:
COLUMN(A$2:D$8)
returns the column number for each column within the specified range, i.e.:
{1,2,3,4}
By reciprocating this array with that containing our conditional Boolean TRUE/FALSE returns, we produce an array whose only numerical entries correspond to columns in which our search string (i.e. "James") is located, since:
COLUMN(A$2:D$8)/(A$2:D$8=O2)
which is:
{1,2,3,4}/{TRUE,FALSE,TRUE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,TRUE,FALSE,FALSE;FALSE,FALSE,FALSE,TRUE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE}
becomes:
{1,#DIV/0!,3,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,2,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,4;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!}
by virtue of the fact that, when subjected to a suitable mathematical operation (of which division is one), Boolean TRUE/FALSE values are coerced into their numerical equivalents (TRUE=1, FALSE=0), meaning that, effectively, for any numerical value x:
x/TRUE ⇒ x/1 = x
and:
x/FALSE ⇒ x/0 = #DIV/0!
By setting AGGREGATE's first parameter to 14 (equivalent to the function LARGE) and its second to 6 (instructing it to ignore any errors in the array passed), we can extract the largest column index which meets our criterion, such that:
AGGREGATE(14,6,COLUMN(A$2:D$8)/(A$2:D$8=O2),1)
which is here:
AGGREGATE(14,6,{1,#DIV/0!,3,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,2,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,4;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!},1)
returns 4.
All that is left is to pass this value to INDEX, such that:
INDEX($1:$1,AGGREGATE(14,6,COLUMN(A$2:D$8)/(A$2:D$8=O2),1))
which is:
INDEX($1:$1,4)
returns:
13/11/2015
as required.
Regards

Resources