Podio app calculation - round off to two decimal places - decimal

I have a Podio app that multiplies a couple of numbers in two different number fields (see screenshots) and puts the result in the "Total to be Paid" field. The problem is that it doesn't round off to two decimal places. Some times it does, other times it does not. Sometimes it displays 3 decimal places, sometimes a lot more than that. How can I get it to round off to 2 decimal places?
The code I put in the calculation field is
"$" + #Number of Hours Worked (from timedoctor.com) * #Hourly Rate
http://screencast.com/t/85cxDP2CUWJ

Please try:
function numberWithoutCommas(x) {
return parseFloat(x).toFixed(2).toString();
}
"$" + numberWithoutCommas(#Price * #Count)
#Price and #Count have to be replaced with your variables, and those are number in my example.

Related

Excel - How to add words to an Excel IF statement

I am creating a spreadsheet for a Dungeons and Dragons game that I run to help measure initiative and turn orders.
The formula I'm trying to do is to convert the rounds passed into real time.
1 Round being 6 seconds, 10 rounds being 1 minute.
I think the math is fine, the problem is adding the words "Seconds" when the value of Rounds passed is equal to 2-9, and greater than 10.
This is the formula I have now:
=IF(I3=10,"1 Minute",IF(I3=1,"6 Seconds",IF(I3>1,I3*6+" Seconds")))
(I3 being the Rounds Passed cell)
You build strings with the & operator, not the + operator.
=IF(I3=10,"1 Minute",IF(I3=1,"6 Seconds",IF(I3>1,I3*6 & " Seconds")))

Converting number to time in excel - variable number of digits

I have a report which is downloaded from a Warehouse Management System.
On this report there is a time column which unfortunately puts the time into a string of numbers that can be anywhere from 5-8 digits long.
I.e.
22434900 = 22:43:49:00 with 22 being the hour, 43 the minutes, 49 the seconds.
2480000 = 02:48:00:00 with 2 being the hour, 48 the minutes etc.
54300 = 00:05:43:00
The 00 on the end (milliseconds) doe not change in each number so is quite irrelevant.
Is there an easy way to format the text in these cells so it shows as a time as oppose to a number?
Thanks in advance.
I know I'm late, but here's an alternate solution:
=TIMEVALUE(TEXT(A1/100,"00\:00\:00.00"))
Again, as mentioned in Jerry's answer, you'll need to use cell formatting of hh:mm:ss.00
You can use TIME with some math functions:
=TIME(INT(A1/1000000),MOD(INT(A1/10000),100),MOD(A1/100,100))
TIME takes 3 parameters: hours, minutes and seconds.
To get the hours, I'm dividing by 1000000, then INT rounds it down to the closest integer.
To get the minutes, I'm first dividing by 10000, but there is still the hours in that result. So I use MOD (which gives the remainder when a number is divided by another number). In the first example, the division gives 2243, and the remainder when dividing this by 100 is 43, which is the number of minutes I'm looking for.
To get the seconds, I divide the number by 100 and similar to the minutes, I use MOD to remove the minutes and hours parts. I am not using INT here in case there are milliseconds, which will be kept using this formula.
Also note that I am using the formatting hh:mm:ss.00, because excel complains if I try using hh:mm:ss:00.
For your Warehouse Management System query you may want to try something like this:
• Taking the 6 digit numeric time and making this into a string that the time function can handle
• Using the digits function to avoid issues with varying lengths of data (i.e. 64512 vs 1113012)
• Use the function Time over this string to return the value (this way we can add hours or minutes as the example below)
Here is an example to experiment with this and :
select MyTimeField
, time(int(MyTimeField/10000) || ':' ||
substring(digits(MyTimeField),3,2) || ':' ||
substring(digits(MyTimeField),5,2))
from MyTable where MyCompany = 1 and MyInvoiceDate = Current_date

Rounding number in SSRS2008-R2 Reports

I have a report in RS.
One of the cells in my tablix have the following expression:
=Round((Fields!Volume.Value * 100) / First(Fields!Volume.Value,"RankingProduct"),2)
As you cann see, Im doing a Rule of three so the total is my first row of the Volume field.
Now, all the elements must sum 100%, but it does only if I take the Round function out.
The customer wants to see 2 decimals but at the same time wants all the elements to sum 100%. I understand both are mutually exclusive.
Example:
Value with all decimals: 0,005100972740331660000000000000
Value with the 1st two decimals rounded: 0,010000000000000000000000000000
So if you have one or two thousand of these will never reach 100% as I lose the precision.
So the only solution would be to leave all the decimals?
You can operate the simple calcul without rounding in the expression
=Round((Fields!Volume.Value * 100) / First(Fields!Volume.Value,"RankingProduct"),2)
become
=(Fields!Volume.Value * 100) / First(Fields!Volume.Value,"RankingProduct")
Then, you right click on the text box, choose Text box property -> Number, and you can select the 2 decimal display.

Truncate to the nearest thousandths and ignore the remainder of the value

Can MS Excel do rounding but only up to the nearest thousandths place and ignore the rest of the decimals in a formula? I've tried value, fixed, round and none of these do what I need.
Let's say I have 100 square feet of space and I pay $1.00566399 per sq foot, I need the formula to round only up to the 5 and ignore the rest of the numbers because when you speak on longer terms it makes a difference in rate.
So I should be multiplying 100sf by $1.01 = $101.00 and not get 100sf * 1.00566399 = $101.57
=trunc(A1,5)
If you want to round up, maybe something like
=trunc((A1*10000+1)/10000,5)
Use the TRUNC($cellRef or number, Decimal places) function. It reduces the number of decimal places WITHOUT rounding, then do your math.
So for example:
=TRUNC(1.00566399,3)
=A1*ROUNDUP(B1,2)
Where A1 contains the number of square feet and B1 contains the price per square foot in it's original long decimal form.

Rounding error when using INT function

I have user input in two cells, named "UpperRangeHigh" and "UpperRangeLow". I have the following code:
dRangeUpper = [UpperRangeHigh] - [UpperRangeLow]
lLines = Int(dRangeUpper * 100 / lInterval)
The user inputs 120.3 and 120 into the input cells respectively. lInterval has the value 10. VBA produces the result of 2 for lLines, instead of 3.
I can overcome this problem by adding 0.000000001 to dRangeUpper, but I'm wondering if there is a known reason for this behaviour?
This appears to be a problem with Excel's calculation and significant digits. If you do:
=120.3 - 120 and format the cell to display 15 decimal places, the result appears as:
0.2999999999999970
Here is a brief overview which explains how Excel uses binary arithmetic and that this may result in results divergent from what you would expect:
http://excel.tips.net/T008143_Avoiding_Rounding_Errors_in_Formula_Results.html
You can overcome this by forcing a rounded precision, e.g., to 10 decimal places:
lLines = Int(Round(dRangeUpper, 10) * 100 / lInterval
Kindly use single or double when working with decimals to get more accurate results.
Sub sample()
Dim dRangeUpper As Double
dRangeUpper = CDbl("120.3") - CDbl("120")
lLines = Round(CDbl(dRangeUpper * 100 / 10), 4)
End Sub
output = 3
This is a known Floating point issue within Excel
http://support.microsoft.com/kb/78113
From MSDN:
To minimize any effects of floating point arithmetic storage
inaccuracy, use the Round() function to round numbers to the number of
decimal places that is required by your calculation. For example, if
you are working with currency, you would likely round to 2 decimal
places:
=ROUND(1*(0.5-0.4-0.1),2)
In your case, using round() instead of INT should do the trick using 0 rather than 2

Resources