Knowledge Management

Macro Validation Expression Error?

jluo_splunk
Splunk Employee
Splunk Employee

I made a macro, we'll call it "test" defined as

 eval new_rate=$val$*$rate$

with the validation expression just checking rate to make sure it's a number

isnum($rate$)

When I call the macro.. I end up with something like test(revenue, .79) When I do this, Splunk says my rate failed validation because .79 is considered a string. When I pass 0.79, it passes as expected. Is this intentional, or a bug? Additionally, is there a function that would pass .79 as a number?

0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

test(revenue, tonumber(.79))

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this:

test(revenue, tonumber(.79))
0 Karma

jluo_splunk
Splunk Employee
Splunk Employee

Wonderful, thank you woodcock!

0 Karma

woodcock
Esteemed Legend

Note that I just retried all this in v6.5.0 and not only is tonumber not necessary but it generates an error now (the same error that this solution was proposed to solve)!

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...