cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to know if an variable is numeric?

Hi everyone!!

Hope can help me, with my problem.

I want to know how I can evaluate an variable to know if is numeric, but I can´t resolve.

 

I read about the function isnumeric but is not avaible on Microsoft Flow :(.

 

And I don´t know how resolve this, somebody can give me another way, how I can do this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How to know if an variable is numeric?

Hi @FlorC ,

 

You could refer to screenshot below to create the flow:

1.png

 

You should save the variable in a Compose.

The expression in the Comoose 2 as below:

 

int(outputs('Compose'))

 

The Compose 4 action would run after the Compose 2 has run failed:

2.png

 

So if the variable is numeric, the Compose 3 would run, if the variable isn't variable, the Compose 4 would run.

You could add send email action under the Compose 3 and Compose4 with the result.

 

Best regards,

Alice   

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: How to know if an variable is numeric?

hi @FlorC  what you can to enshure a numeric value is use the expresion int() and inside your number. or you can create an array with numbers to see if your output contains numbers inside.

contains.PNG



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Community Support
Community Support

Re: How to know if an variable is numeric?

Hi @FlorC ,

 

You could refer to screenshot below to create the flow:

1.png

 

You should save the variable in a Compose.

The expression in the Comoose 2 as below:

 

int(outputs('Compose'))

 

The Compose 4 action would run after the Compose 2 has run failed:

2.png

 

So if the variable is numeric, the Compose 3 would run, if the variable isn't variable, the Compose 4 would run.

You could add send email action under the Compose 3 and Compose4 with the result.

 

Best regards,

Alice   

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

Highlighted
New Member

Re: How to know if an variable is numeric?

The xpath shown here will convert your string value to a float

xpath(xml(json('{value:"99"}')),'number(*/text())')

The above will return a float for 99

 

xpath(xml(json('{value:"hello world"}')),'number(*/text())')

The above will return a float for NaN 

 

If NaN is returned, a conditional evaluation such as the one shown below, will not error and would return false

ScottMoore_1-1596657242135.png

 

 

 

Here it is being used with a variable named office...easier for copy & paste in case I end up back here myself 🙂

xpath(xml(json(concat('{value:"',variables('office'),'"}'))),'number(*/text())')

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,594)