We have job numbers most with a leading 1, with 7 digits to follow. There is one set, that leads with a 6, and is 6 digits. I need a leading '0' on both
The below formula captures the '0', for job numbers leading with a 1, with 7 digits, but not the items leading with a 6, with 6 digits:
Z Sage ID = IF(LEFT('Sales
Force_Contract'[Account_Number__c],1)="1",CONCATENATE("0",'Sales
Force_Contract'[Account_Number__c]),'Sales Force_Contract'[Account_Number__c])
Here's what I tried, and received this error:
Z Sage ID = IF(LEFT('Sales
Force_Contract'[Account_Number__c],1)="1",IF(and('Sales
Force_Contract'[Account_Number__c]="6",CONCATENATE("0",'Sales
Force_Contract'[Account_Number__c]),'Sales Force_Contract'[Account_Number__c])))
'Too many arguments were passed to the AND function. The maximum
argument count for the function is 2.'
Can you help get on the right track?
The easiest way is to use operators that don't require you to add words like AND()
Read more about it here.
The following code should work:
Z Sage ID =
IF (
LEFT('Sales Force_Contract'[Account_Number__c],1) = "1" ||
LEFT('Sales Force_Contract'[Account_Number__c],1) = "6",
"0" & 'Sales Force_Contract'[Account_Number__c],
'Sales Force_Contract'[Account_Number__c]
)
How it works:
It checks if the left number is either a 1 or (Or = ||) a 6.
If yes, it adds a leading 0 (One & (&) to concatenate, two & (&&) to get the AND() function)
If no, it takes the original account number.
This question already has answers here:
ultimate short custom number formatting - K, M, B, T, etc., Q, D, Googol
(3 answers)
Closed 1 year ago.
I've looked everywhere and haven't found any solutions to getting numbers in the "Trillions" to format with a trailing "T".
Here is the custom number format I'm currently using: [<999950]$0.00,"K";[<999950000]$0.00,,"M";$0.00,,,"B"
Which displays these numbers as so:
Is Google Sheets also able to make numbers in the Trillions format as $1.00T?
Thanks!
not possible. this "internal" formatting is by default able to work with only 3 types of numbers:
positive (1, 2, 5, 10, ...)
zero (0)
negative (-3, -9, -7, ...)
this can be somehow tweaked to show custom formatting like K, B, M but you always got only 3 slots you can use, meaning that you can't have trillions as the 4th type/slot
however, this would cover your needs:
=ARRAYFORMULA(IF(ABS(A:A)<10^3, A:A&"",
IF(1*ABS(A:A)<10^6, TEXT(A:A/10^3, "#.0\k"),
IF(1*ABS(A:A)<10^9, TEXT(A:A/10^6, "#.0\M"),
IF(1*ABS(A:A)<10^12, TEXT(A:A/10^9, "#.0\B"),
IF(1*ABS(A:A)<10^15, TEXT(A:A/10^12, "#.0\T"),
IF(1*ABS(A:A)<10^18, TEXT(A:A/10^15, "#.0\Q\a"),
IF(1*ABS(A:A)<10^21, TEXT(A:A/10^18, "#.0\Q\i"),
IF(1*ABS(A:A)<10^24, TEXT(A:A/10^21, "#.0\S\x"),
IF(1*ABS(A:A)<10^27, TEXT(A:A/10^24, "#.0\S\p"),
IF(1*ABS(A:A)<10^30, TEXT(A:A/10^27, "#.0\O"),
IF(1*ABS(A:A)<10^33, TEXT(A:A/10^30, "#.0\N"),
IF(1*ABS(A:A)<10^36, TEXT(A:A/10^33, "#.0\D"),
IF(1*ABS(A:A)<10^39, TEXT(A:A/10^36, "#.0\U"),
IF(1*ABS(A:A)<10^42, TEXT(A:A/10^39, "#.0\D\d"),
IF(1*ABS(A:A)<10^45, TEXT(A:A/10^42, "#.0\T\d"),
IF(1*ABS(A:A)<10^48, TEXT(A:A/10^45, "#.0\Q\a\d"),
IF(1*ABS(A:A)<10^51, TEXT(A:A/10^48, "#.0\Q\u\d"),
IF(1*ABS(A:A)<10^54, TEXT(A:A/10^51, "#.0\S\x\d"),
IF(1*ABS(A:A)<10^57, TEXT(A:A/10^54, "#.0\S\p\d"),
IF(1*ABS(A:A)<10^60, TEXT(A:A/10^57, "#.0\O\d"),
IF(1*ABS(A:A)<10^63, TEXT(A:A/10^60, "#.0\N\d"),
IF(1*ABS(A:A)<10^66, TEXT(A:A/10^63, "#.0\V"),
IF(1*ABS(A:A)<10^69, TEXT(A:A/10^66, "#.0\C"), ))))))))))))))))))))))))
This question already has answers here:
generate random double numbers in c++
(10 answers)
Closed 4 years ago.
I need to randomly generate numbers (using random()) from -1 to 1 that are doubles. For example the output would be something like:
1,
-0.3324,
0.7821,
0.9823,
-0.111
etc... this is what I was trying to do walk_Length = (double)rand()%2 - 1;
You might get away with something like
double walk_Length = static_cast<double>(rand()) / RAND_MAX * 2 - 1;
This question already has answers here:
JavaFX TextField Array max length of text value
(1 answer)
How to restrict TextField so that it can contain only one '.' character? JavaFX
(3 answers)
Java 8 U40 TextFormatter (JavaFX) to restrict user input only for decimal number
(1 answer)
Numeric TextField for Integers in JavaFX 8 with TextFormatter and/or UnaryOperator
(4 answers)
Closed 5 years ago.
I need to limit input length to 4 digits in JFX textField (field can be empty or have value 0-9999). Below solution works only partially - I can input only digits , but as many as i want - limit do not work. Even if I remove {0,4} from regex and
change IF condition to:
if(newText.matches("\d") && newText.length()>=0 && newText.length()<5)
it doesn't work too. Where is the error?
JFXtextField.textProperty().addListener((obs, oldText, newText) ->
{
if(newText.matches("\\d{0,4}"))
{
newText = newText;
}
else
{
newText = oldText;
}
});
This question already has answers here:
R: convert list of numbers from character to numeric
(3 answers)
Closed 7 years ago.
Suppose I have the character string
x <- " 1.1325 -0.9022 -0.1832 -0.5479 0.1236 -0.6556 -1.0599 -0.8881 -0.2136"
and I want to extract the floats to end up with this vector as output:
c(1.1325, -0.9022, -0.1832, -0.5479, 0.1236, -0.6556, -1.0599, -0.8881, -0.2136)
What I managed to achieve is:
na.omit(as.numeric(strsplit(samp, split = " ")[[1]]))
My question: Is there a more efficient way?
We can use scan
scan(text=x, what=numeric(), quiet=TRUE)
#[1] 1.1325 -0.9022 -0.1832 -0.5479 0.1236 -0.6556 -1.0599 -0.8881 -0.2136