In Amazon Athena, I want to round a big number to output me as decimal precision 2.
For example, I have 1.4309491454947177E11 which is equivalent to 143094914549.47177, so I expect result to be 143094914549.47
I am doing
SELECT ROUND(1.4309491454947177E11, 2)
But it is giving me wrong output 1.43.
Any help would be much appreciated!!!
The output is correct it is converting it to 2 decimals and you can use it in any downstream. It is just displayed as exponential. Similar to the way you see in excel and when you click on excel cell it displays actual value.
If you want to see data in 2 digit format.Cast will work make sure no of digits in cast is more than actual value
select cast(Round(1.4309491454947177E11 ,2) as decimal(20,2))
Related
Image of the problem (https://i.stack.imgur.com/Ie0ZV.png)
The IF formula is supposed to give the answer yes if the two values are the same, which they are. Although I get the answer No. Why is this happening?
The two values are themselves formulas from other sheets.
Image of attempt to solve (https://i.stack.imgur.com/qetL3.png)
I tried to use numbers directly put in the same sheet (no numbers coming from a formula), and then it works. But I need to use values that are based on formulas taking numbers from other sheets.
while the values derived from the formulas is just showcasing 2 decimal places, its likely that when you expand/increase the decimals to extreme end there could be a possible difference (alike the one you can see in the screenshot for reference; the EXACT() in Cell B3 throws 'FALSE')
You could ROUND() them up for exact match scenario.
I'm kind of new to DAX and I'm basically learning as I'm using it in my work. We are building reports in PowerBI and we have data model that gets data from Oracle database. So I'm using DAX to create measures in this data model.
I need to substract 2 numbers from each other. So I created simple measure which looked like this:
[MEASURE1] - [MEASURE2]
Whether it works or it doesn't depends on my Period filter which uses another table. I don't know how could period be related to any of this. So when I change filter to some values, I get normal number. However, when I switch it to different values, I get numbers like 2,27483058473905E-13.
Weird thing is that if I check those two measures that I'm subtracting, they have exactly the same numbers, so the difference should be 0.
I know this is not the best explanation, but it is impossible to describe entire data model here. So I'm just looking for some ideas what could possibly be causing this and what should I check.
I have literally no idea what could be causing this.
Floating point precision.
Either use fixed decimal data types, specify the format string of the measure, or wrap your measure in ROUND, e.g.:
Diff =
ROUND (
[Measure 1] - [Measure 2] ,
2
)
2,27483058473905E-13 is not a huge number, but as close as a decimal calculator can get to zero.
I can't believe I have never had this issue before (nor can I find anyone else with the same issue) but today I have just discovered that SAS sometimes gets simple calculations wrong!?! I noticed that one of my records wasn't getting picked up in the right group based on a value being <3.6 and thought there must be something strange in my data with decimal places. But on investigation I found it was just because SAS was calculating the value wrong! For some reason that I can't fathom, it seems that SAS calculates 90 - 86.4 as 3.59999999999999!!! Simple program below to show this:
code
output
If I alter the calculation to 10 - 6.4 I get the correct value of 3.6000 but for some reason this one is coming out wrong. Could there be some mad setting that is wrong in my installation? I tried both SAS EG and Base SAS and both have the same issue. I feel like I'm going mad! Any help appreciated.
Thanks.
Floating point arithmetic, in any language, will have this same issue. The same issue is possible to understand in human terms, assuming the human doesn't have a concept of infinite. If you only write down 4 digits for your decimals, for example, then:
1 - (1/3) - (1/3) - (1/3)
That's zero, right?
1 - 0.3333 = 0.6667
0.6667 - 0.3333 = 0.3334
0.3334 - 0.3333 = 0.0001
Nope! Computers do the same thing, but in binary, so they have a different (and larger) set of "problem" numbers. 1/10, for example, is not representable in binary - so adding or subtracting 0.1 is not always a "neat" operation like it is in decimal.
SAS uses 8 byte floating points, and so it gets ~15 digits of accuracy. Assuming you're not working in a field where 15 digits of accuracy is needed, you should simply round.
if round(value,.01) ge 3.6 then ... ;
Most of the time this isn't needed, but strictly speaking you should always compare rounded numbers whenever using floating point numbers (as SAS does). Integers are safe, but if you're working with 0.1 etc., use ROUND or FUZZ for integers.
Sorry Cannot replicate your findings.
data x;
a=90-86.4;
run;
Gives the correct result. Are you using any formats or put function. Share the complete code.
I have problem with conversion from binary to decimal value.
I keep every bit of binary number in the another cell so I'm looking for some tip how to connect that number into one row using some automatic function and then use BIN2DEC function.
On the picture I wanted to show you what I want to do.
Use something like "=BIN2DEC(CONCATENATE(A1;B1;C1;D1;E1;F1;G1;H1))" to achieve the desired decimal value.
I have few form fields where user can enter whole numbers, decimal numbers and both types can be positive or negative. In other words they can enter something like this:
1 or 0.9 or 5.6745 or -10 or -0.9 or -10.5435
I'm wondering what I should use in my cfqueryparam on cfsqltype? I tried decimal but looks like that is not supported in ColdFusion 9. Is there any other option or I should use varchar?
Use the option that matches the column in your database. By selecting the correct value, Coldfusion will try to validate and format the value before it is sent off to the database driver.
With fix precision types cf_sql_numeric and cf_sql_decimal you need to also specify the scale (number of decimal places) your column accepts. By default the scale is 0, and will only store an integer number. Once again check your database for the scale.
For non precision types such as cf_sql_float no scale should be specified and the full value is sent off to the database.
Full list of data types can be found in the Adobes docs.