Flutter Get Number Value from Currency format - dart

currently my textfield display in currency format example
IDR 120.000
and i want to get the value as 120000, how can i get that value easily?

I would split at the space and parse the remaining part:
var numValue = double.tryParse(currValue.split(' ')[1])

Related

Value imported can't be changed to a number

I'm using the function importhtml() on my Google Sheets :
=IMPORTHTML("https://fbref.com/fr/comps/13/Statistiques-Ligue-1";"table";3)
The data are imported but some data are displayed "01.08" and the value is a date. The other values are ok if they contains big number like 1.93. How it's possible to change that and have only numbers and not displayed that value as a date ?
I try to change the format of the cell but the value became a number like 44455.
This is a screen of what I have
Just with the importHTML without any cell formatting
After I format the cell as brut text
How can I have the value as a number so to display 1.08 and not 01.08 ( for Google SHeets this is a date )
Thanks a lot in advance
Just add a fourth parameter, which stands for locale.
=IMPORTHTML("https://fbref.com/fr/comps/13/Statistiques-Ligue-1";"table";3;"en_US")
This solved the problem here, since it turns the decimal points into commas, not allowing GS to interpret it as date format.

Remove trailing ".00" from numbers in Google Sheets

In Google Sheets I'm trying to format numbers to have format "0.##" - so that integer be like integer (12 be exactly 12), decimals be like decimals with no trailing zeroes (12.30 be 12.3 and 12.4321 be 12.43), but in reality
for 12 I've got 12. with this annoying decimal point and see NO WAY to get rid of it.
The same time if I choose Format -> Number -> Automatic, I've got calculated numbers be like 131.3666667 which is not my desired format.
In LibreOffice using format "0.##" removes unnecessary decimal point, but Google Sheets don't. If you know how to do it, please share your knowledge. Googling doesn't help much.
Thank you in advance!
Number format 0.## works well with Google Apps Script. It does not leave dot to numbers that has no decimals.
The code below will apply number formatting to the whole Sheet.
Try this:
function formatColumn() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var range = sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns());
range.setNumberFormat("0.##");
}
*Note:
You can change the range to column specific by changing the value of getRange(). Example: sheet.getRange(A1:A).
If you choose to format the whole sheet, you only need to run the script once to apply the format.
Output:
Before:
After:
Since we set the format to the whole sheet, It will automatically format any inputted numbers.
Reference:
Google Apps Script
Class Range
Range.setNumberFormat(numberFormat)
hi i found the Solution :
For Example let us say that you have the number 100 in the cell A1 ,
and you have the Number 99.9 in the cell B1 .
let us say you want to get the sum of them without having the.9 .
click on the cell that you want to add the sum on it :
let us say it is the cell C1 click on it then add =INT //(MUST BE CAPITAL) :
for example :
= INT(A1 + B1)
then hit Enter .
now the value of the sum is :
199
If you don't use the result of these cells for further calculation (or if you do use, but don't mind losing some precision), you can surround your current formula with Round(..., 2) and leave the format as automatic.
Some examples of what original numbers will appear as:
1.004 -> 1
1.006 -> 1.01
1.096 -> 1.1

Using number formatting on a scientific number changes the value

I have a string which is eval_id = -8880305704784521238 in google sheet.
When I used split formula =SPLIT(A1,"=") it gives me result in scientific number
eval_id -8.88031E+18
But when I used number formatting it changes the value of the number.-8880305704784520000 which is not equal to the actual number -8880305704784521238.
How can I fix this issue.
Try this:
=REGEXEXTRACT(A1,"-*\d*.?\d+")
or as an array formula (specify the range):
=ARRAYFORMULA(REGEXEXTRACT(A1:A15,"-*\d*.?\d+"))

Maximum value in a row where the data is a string containing an integer

What I am trying to do is get the maximum from a row containing data which is of the form "x kg" where x is an integer but overall this forms a string. The issue is that running a =MAX(C5:AA5) over this returns 0 (for obvious reasons).
I thought about using another formula =LEFT(C5, LEN(C5) - 3) but the issue with this is that it only works for a single cell.
How can I (using a script if necessary), get the maximum value in the row knowing the row is only strings with integers in string format in them?
My rows look something like this: (note that commas represent another cell)
"20 kg", "30 kg", "40 kg", "50 kg", ...
You could create a custom number format instead of adding the text "kg". Select Format > Number > More Formats > Custom Number Formats > and enter 0 "kg" in the text field. Now that format will be saved for you, you can apply it to your whole row and get the MAX() formula working correctly for you while keeping your visual format.
shorter solution:
=ARRAYFORMULA(MAX(VALUE(SUBSTITUTE(A20:A, " kg", ""))))
=ARRAYFORMULA(MAX(IFERROR(VALUE(REGEXEXTRACT(A20:A, "\d+")))))
even shorter:
=ARRAYFORMULA(MAX(IFERROR(SPLIT(A20:A," "))))

Display text representation of a date as a formula result

I get this date format from Zapier
2018-08-16T01:13:58
I use this formula to split and extract the first half of the split (the date).
=index(SPLIT("2018-08-16T01:13:58","T"),0,1)
Google Sheets displays the formula output as a number, e.g. 43328
If I format this cell manually, using the menu Format >> Number >> Date, Google Sheets will display it as the formatted date, e.g. 16/08/2018
If I use DATEVALUE() as such:
=datevalue(index(SPLIT("2018-08-16T01:13:58","T"),0,1))
then the cell displays #VALUE!
Error DATEVALUE parameter '43328' cannot be parsed to date/time.
How can I write my formula such that it is displayed as formatted date, without having to format the formula's cell through the menu?
You can use the TEXT function:
=TEXT(43328,"dd-mm-yyyy")
Date shows in google spreadsheet are formatted by google spreadsheet settings. If you want to change the datetime format of your sheet, you will have to change Locale setting to that of your need.
If you don't want to go over settings, you can set it manually by code.
First, you will need to put this formula =SPLIT("2018-08-16T01:13:58","T") + "" somewhere to get the date value. Here I assume you use cell "Z1"
Now, you will have to change the date format each time "Z1" changes it value. I use onEdit(e)
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSheet()
if (range.getColumn() == 26 && range.getRow() == 1) { // if Z1 is modified
var d = ss.getRange("Z1").getValue()
var inputDate = Utilities.formatDate(d, "GMT+7", "dd/MM/yyyy")
ss.getRange("B5").setValue(inputDate)
}
}
There you go. Each time Z1 change, which means the date value is inputted, the correct date + format will be reflected in B5.
After much searching this seems to work for me.
=regexreplace(SUBSTITUTE(SPLIT("2018-08-16T10:02:29","T") + "","-","/"), "^(\d+).(\d+).(\d+)$", "$3/$2/$1") & " " & regexreplace(RIGHT("2018-08-16T10:02:29", find("T","2018-08-16T10:02:29") -3), "^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$", "$1:$2:$3")
Outputs 16/08/2018 10:02:29

Resources