Please help me to create a decimal value random generator in postman.
pm.environment.set("variable", Math.floor(Math.random() * 50.50));
Tried the above code but no use
it's simple
Just add "true" as third parameter of random's function
Ex: var decimalRandom = _.random(1,10,true));
Returns "8.886340078880954" i.e
You can just use Lodash for this as it's a built-in module:
pm.environment.set("random_number", _.random(1, 50))
Or just add the number 50 to the _.random() function and this will be a number from 0 to 50.
Related
I want to find the minimum number with given conditions(is writer and is under probation), the below code works if D contains numbers, but how do I do it if the number is a part of a string, like a fraction for example? Like how do I use this formula if numbers in D look like "1/8", "31/688", "21/33", etc?
=MINIFS(D3:D1007, A3:A1007, "Writer", C3:C1007, "Probation")
I already have another formula that I use that calculates a decimal value given the fraction, If the fraction is in cell D21 then it would look like this:
=left(D21,find("/",D21)-1)/(right(D21,len(D21)-find("/",D21)))
but how do I apply this kind of formula in a minif/maxif?
I have attached a picture to show what I mean, what I'm trying to do is to put a formula in the passed/total column of package stats(probation), and it will get the lowest passed/total value out of the ones with that package name and importance level. as you can see, the entire writer package's pass rate is 5/8 because the lowest pass rate out of the writer package 5/8 is the lowest pass rate out people with package=writers and importance = probation. But at the moment I have to enter the 5/8s manually, I want it to be able to get it automatically using the formula I'm trying to figure out above.
try:
=ARRAYFORMULA(MIN(IF((A3:A="writer")*(C3:C="probation"),
IFERROR(REGEXEXTRACT(D3:D, "\d+")/REGEXEXTRACT(D3:D, "/(\d+)"), D3:D), )))
or to return fraction:
=ARRAYFORMULA(VLOOKUP(MIN(IF((A3:A="writer")*(C3:C="probation"),
IFERROR(REGEXEXTRACT(D3:D, "\d+")/REGEXEXTRACT(D3:D, "/(\d+)"), D3:D), )),
{IF((A3:A="writer")*(C3:C="probation"),
IFERROR(REGEXEXTRACT(D3:D, "\d+")/REGEXEXTRACT(D3:D, "/(\d+)"), D3:D), ), D3:D}, 2, 0))
also make sure fractions are formatted as plain text not date
I am setting up a new spreadsheet in google spreadsheets and I need to set a max value because it can surpass that number.
I am currently using this formula -> =SUMPRODUCT(D17:D33) and that sum can be more than 50, and if that's true, I want to limit to 50.
Any tips?
Please try:
=min(50;sumproduct(D17:D33))
try something simple like:
=IF(SUMPRODUCT(D17:D33)>50; 50; SUMPRODUCT(D17:D33))
I'm using Google Gauges and would like to add a % sign after the value in the gauge. My values display with fine without the percent symbol (whole numbers 0 - 100), but when I start trying to add the percent symbol things get wonky.
Here's what I've tried
// Format the data to include % symbol
var formatter = new google.visualization.NumberFormat(
{suffix: '\u0025'}
//{suffix: '%'}
//{pattern: '#%'}
);
All three attempts display the correct visualization, but for the actual value text I get varying results.
Using either suffix method it adds two decimal places:
6 => 6.00%
26 => 26.00%
and so on
Using the pattern method it multiples the value by 100
6 => 600%
26 => 2600%
and so on
Any clue on how to simply display the value along with a percent symbol?
It's simpler than all that. If you just make a number formatter, specifying the pattern, and the suffix, you're all set:
http://jsfiddle.net/fHnnn/
I have list in format
"4186.0,7573.0,4300.0,9479.0,9488.0,10642.0,7987.0,9480.0 "
Is there any function in coldfusion available, which removes all ".0" from numbers in one go?
Thank you.
You could use map() from the UnderscoreCF library to gracefully solve this problem (in CF 10 or Railo 4).
_ = new Underscore();
listOfNums = "4186.0,7573.0,4300.0,9479.0,9488.0,10642.0,7987.0,9480.0 ";
arrayOfNums = _.map(listOfNums, function(num){
return round(num);
});
result = arrayToList(arrayOfNums);
map() produces a new array of values by mapping each value in the collection through a transformation function. This allows you to have more control over the results.
Note: I wrote UnderscoreCF.
There isn't a simple function to do this, but there are a number of things you can do.
You can loop through the list and numberFormat() each item, placing it back in the list or creating a new list. This is inefficient, both in processing and in programming.
Because your list is just a string, you can replace the decimal part of your numbers with a simple string replace: replace("123.0,456.0", ".0", "", "ALL"). If your list ever grows different decimal digits other than ".0", you can upgrade that replace function to a regular expression to catch patterns of numbers.
I usually use INT to drop the decimal of a number like barnyr suggested but if you wanted to treat it as a single string and not a list you could use reReplace (to elaborate on Nathan Strutz's idea) and do something like:
<cfset listOfNums = "4186.0,7573.540,4300.434,9479.,9488.0,10642.0,7987.0,9480.0">
<cfset listOfNums = reReplace(listOfNums, "\.[0-9]*", "", "all")>
Result is: 4186,7573,4300,9479,9488,10642,7987,9480
it also removes the decimal point even if no numbers follow.
It sounds like the Int() (equivalent of the floor() function in most other languages) function may be what you want: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f89.html
You'll still need to iterate over the list, applying the Int() function though.
I have a FloatField which can have values like 22.33405, 33.567 etc. Now, I need to query using only upto 2 places after decimal like below
#find all objects with value equal to 22.33
ModelName.objects.filter(field = 22.33)
Is it possible to do so - can I round off or just take first 2 places after decimal?
thanks
try this
ModelName.objects.filter(field__gte=22.33, field__lt=(22.33 + 0.01))
or
ModelName.objects.filter(field__range=(22.33, 22.33 + 0.01))
range lookup
Not directly. If you need this level of accuracy then you should be using DecimalField.