> ## Content Index
> Fetch the complete content index at: https://www.vizney.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Find First Non-Zero Digit after Decimal Point
- URL: https://www.vizney.com/first-non-zero-digit-after-decimal-point/
- Published: 2024-11-27T03:00:00.000Z
- Updated: 2024-11-27T14:13:26.000Z
- Description: Using regular expressions, you can determine the first non-zero digit after the decimal point, making this method ideal for handling varying decimal places.
- Author: Yehwan Hwang
- Tags: Tips & Tricks

In scenarios like exchange rates or stock prices, decimal precision can vary, making it difficult to standardize rounding. For newer metrics or financial instruments like cryptocurrencies, there's often no established convention, leading to inconsistent decimal places across platforms.

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/investing_com.png)

Source: [Investing.com](https://www.investing.com/crypto?ref=vizney.com)

For instance, [Kraken](https://www.kraken.com/?ref=vizney.com) only displays the first two non-zero digits after the decimal for prices less than 1, improving readability. This guide demonstrates how to process decimal places similarly for a few sample cryptocurrency prices.

---

### **Step-by-Step: Displaying the First Two Non-Zero Digits After the Decimal**

We'll process decimal places for four cryptocurrency prices following [Kraken](https://www.kraken.com/?ref=vizney.com)'s approach.

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/Target-List.png)

---

1. **Connect to the data source.**  
Use a dataset containing coin prices. For this example, data from [Investing.com](https://www.investing.com/crypto?ref=vizney.com) was used, where prices are stored as strings with a dollar symbol (e.g., `$0.001234`).

[CryptocurrencyCryptocurrency.csv2 KBdownload-circle](https://www.vizney.com/content/files/2024/11/Cryptocurrency.csv "Download")

💡

It is recommended to keep prices as strings in Tableau to avoid complications with scientific notation (`e` format) or [decimal rounding issues](https://help.salesforce.com/s/articleView?language=en%5FUS&id=001473206&type=1&ref=vizney.com) during conversion.

---

1. **Write a calculated field to find the first non-zero digit.**  
Use a regular expression to locate the first occurrence of a character that is not `$`, `0`, or `.`.

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/First-Non-Zero.png)

Result:

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/First-Non-Zero-Result.png)

---

1. **Calculate the position of the first non-zero digit.**  
Create another calculated field to determine its position relative to the decimal point. Subtract the leading characters (`$0.`) from the total index:

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/Find-Digit-Number.png)

Result:

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/Find-Digit-Number-Result.png)

---

1. **Convert the string price to a floating-point number.**  
Create a calculated field to round the value to one digit beyond the position of the first non-zero digit:

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/Converted-Price.png)

---

1. **Format the final price display.**  
Use a custom format to ensure only significant digits are displayed:

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/Format.png)

Result:

![](https://storage.ghost.io/c/6a/50/6a50f03c-1922-4e90-bf18-c5abd0f819d4/content/images/2024/11/Final.png)

---

This approach ensures clean, readable outputs tailored for financial dashboards or any scenario requiring precise but concise decimal representation.