Introduction

We don’t have an IsNumeric Function in Power automate which can at times become a head ache as some business decisions will depend on the datatype of the data being worked upon. In this article we will see a dirty workaround to identify if the data at hand is Numeric or Text.

Implementation

We will create a basic power automate that can be triggered manually by passing the input which will be the Numeric/Text value to check for the datatype. We will also declare a variable that will hold the decision if the data type is number or not. By default, IsNumeric will be set to true which indicates that the number is numeric.

We will then add a compose action and use the Int function to which we will pass the user input. If the input is a number, the conversion will succeed and the action will not error. However, if the input is a text, the int conversion will fail and the action will error out.

So as to catch the errored-out action, we will add another action set variable where we will set the isNumeric to False.

we will also set the Configure run after setting for this action to ‘has failed’. Thus, the Set Variable action will be invoked only the input is a text and due to which the int conversion will fail. Thus, the variable will have the decision isNumeric = false. If the conversion succeeds (as the input is a number), set variable will not run as the previous action has succeeded and the isNumeric will remain to be True

We will also add another action – Condition to check the final status of the variable and add the check isNumeric is equal to true to test the datatype based on which corresponding branches will be run with their own logic.

One final step to do is that we need to set the configure run after setting for the condition action to run on both Successful and Skipping of the previous step or else by default only the success run of previous action will invoke the condition.

Thus the overall flow would look like:

Test the flow

Let’s manually trigger the flow and pass an Integer value first.

As it is already a number, the 4th step has been skipped and the condition has evaluated to true indicating the numeric nature of the input

Now let’s input a text and trigger the flow

Thus, the compose action has errored out as the Int function couldn’t convert the text to int and the subsequent step to set the variable isNumeric to false has been run. Even the condition has evaluated to false indicating the text nature of the input.

Summary

Thus we saw how we can mimic the IsNumeric function which would help us to check if an input is numerical or textual based on which we can perform some follow up logic