Can a custom metric be a decimal? | Community
Skip to main content
Level 2
Aug 14, 2024 1:43 PM UTC
Question

Can a custom metric be a decimal?

Hi, I’m using the Web SDK to retrieve this data, but I can’t find a way to make it display in decimals as it does on the website. Is there any way within Analytics to ensure the data comes in with decimals? So far, I’ve only managed this with calculated metrics.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

bjoern__koth
New Participant
Aug 14, 2024 3:15 PM UTC

 Hi @krozi 

you could try creating a calculated metric of your current metric and change the decimals as desired in the calculated metric settings.


choose format "Decimal"

 

see also

https://experienceleague.adobe.com/en/docs/analytics/components/calculated-metrics/calcmetric-workflow/cm-build-metrics

 

 

Translate
Cheers from Switzerland!
KroziAuthor
Level 2
Aug 14, 2024 3:18 PM UTC

Yes, it’s a solution I was already aware of, but it would create a "duplicate" of the metric, and I wanted to avoid that.

 

Thank you very much.

Translate
juliusonyancha
Level 4
Aug 14, 2024 2:35 PM UTC

@krozi i have been creating calculated metrics to capture currency format with decimals. However, I came across the thread below, worth trying 

https://experienceleaguecommunities.adobe.com/t5/adobe-analytics-questions/revenue-with-no-decimal-places/m-p/303834  

Translate
KroziAuthor
Level 2
Aug 14, 2024 2:57 PM UTC

I am using the Web SDK to capture this value from the website's Datalayer, so this solution wouldn’t be appropriate for me. Moreover, if you use "parseInt(x).toFixed(n)", it will return an integer with n zeros as decimals (e.g., 124.00). The correct approach would be to use "parseFloat(x)" and then ".toFixed(n)" to limit the number of decimals displayed.

 

Translate