Significant figures in access query

gdesreu

Active Member
Joined
Jul 30, 2012
Messages
318
Does anyone have a formula or function for access 2010 that performs significant figures?
Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Can you explain in more detail exactly what you are trying to do?
 
Upvote 0
Check out the Access Forums. I saw a function posted there once for determining significant figures. AFAIK, there is no Access built in function for this.
 
Upvote 0
I found this yesterday and it seems to work (close enough) It errors if the value field is 0 but I got around that with an iif statement, and correct me if Im wrong but due to the way access handles storing a value like 23.0 as 23, this sig fig calc reports out 23 as opposed to 23.0 in a three sig fig calc. Probably a non issue for me but it might not be for others. Also, this turns the value to a string so after I get the sig fig txt string I just changed it back to a value using a formula in another column.

Code:
   Public Function FormatSigFig(Value As Double, SigFigs As Long) As String
        Dim RoundedValue As Double
        Dim Digits As Long
        Digits = SigFigs - Int(Log(Abs(Value)) / Log(10)) - 1
        FormatSigFig = Int(0.5 + Value * 10 ^ Digits) / 10 ^ Digits
    End Function
 
Upvote 0
Can you explain in more detail exactly what you are trying to do?

Sure, I have a column of numbers, I need to export those numbers out as significant figures. (Im guessing three sig figs at this point) If anyone has a better system than the one I posted Im all ears. Thanks!
 
Upvote 0
If your values always had the same number of digits to the left of the decimal point (i.e. "2"), then you might be able to accomplish what you want with the FORMAT function. Otherwise, you would probably need to use some VBA code, like you have (or some other code).
 
Upvote 0
If your values always had the same number of digits to the left of the decimal point (i.e. "2"), then you might be able to accomplish what you want with the FORMAT function. Otherwise, you would probably need to use some VBA code, like you have (or some other code).
I'm not sure it's that simple. 0 is insignificant if it's at the beginning, but not if in between significant figures (all others), and is if it is after a decimal. Maybe what you had in mind would be ok, though.

gdesreu - Access only drops a single zero after a decimal if that's the way you have it set up. In some cases, it does not drop it at all - it just doesn't show it. Your number data field has to be the correct number type and format if you want zeros after the decimal. As for your function returning a string, that's because it's designed that way ("as string").
What I find odd about it is this line FormatSigFig = Int(0.5 + Value * 10 ^ Digits) / 10 ^ Digits seems to be coercing the value to an integer, only to have the function convert it to a string. You could try changing "as string" to "as Long" or some other number type. If you are not getting the zeros after a decimal and you need them to be counted, you need a better function I think.
 
Upvote 0

Forum statistics

Threads
1,221,846
Messages
6,162,378
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top