cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gofunk1
Helper II
Helper II

Dynamically convert text to number - help

Hi All

 

I need to convert a choice value (string) from a sharepoint list to a number for input into dataverse.

 

I need this to be dynamic,  for example, Business Analyst would be converted to 899400000 and Senior Business Analyst would be converted into 899400001 etc etc. Then the converted number would but mapped to a row input. 

 

I know I can use a condition and compose for this, but this would be a ton of conditions running in parallel for all my choices. 

 

Is there an easier way to do this, maybe using a variable or something else?

 

Help welcome please!

1 ACCEPTED SOLUTION

Accepted Solutions

You should do something like this:

if(equals(outputs('Compose'), 'Business Analyst'),'899400000',if(equals(outputs('Compose'), 'Senior Business Analyst'),'899400001','0'))

In the expression to apply when the condition is false, you should add another if, and so on...

Regards,

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

7 REPLIES 7
fchopo
Super User
Super User

Hi @Gofunk1 

Could be possible to create a SharePoint list like this?

Title RoleID
Business Analyst 899400000
Senior Business Analyst 899400001

You could use the "Get Item" SharePoint action with an Odata filter expression to search for items (based on the "Title" column) within the list and get the "RoleID" value.

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

I dont think that wouldn't work or I'm not understanding how to do it. Here is the flow as it stands, does this make more sense.

 

I'm trying to reduce the amount of conditions I would need as I have a number of choices to convert

 

Gofunk1_0-1639407070471.png

 

I need to convert values of a few more columns so not sure how this would work

fchopo
Super User
Super User

Hi @Gofunk1 

In my sample you have 2 SharePoint lists: NewEmployees (where the item is created) and RolesMapping (where you have the mapping between the Role and the ID (the table I shared with you before). Then, you could create something like this:

1) When an item is created in NewEmployees list

2) Search in the RoleMapping list for the Role Title

3) Get the role ID (first returned row), using the following expression:

first(outputs('get_items'))?['RoleID']

The flow would like this:

roles.png

 So you have a "master" table, which maps the Role Title with the Role ID, and more fields could be mapped. In this way, you don't need to create different if actions.

The last compose action gets the Role ID, so the field value you should enter when creating the record in the dataverse table.

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Thanks I'll try this, but before I do, is there a way to chain a bunch of expressions, for example, see below, how would I get the compose to do an "or operation so I can enter another If statement?

 

I cant do

if(equals(outputs('Compose'), 'Business Analyst'),'899400000','no')
OR
if(equals(outputs('Compose'), 'Senior Business Analyst'),'899400001','no')

 

Gofunk1_0-1639409393875.png

 

You should do something like this:

if(equals(outputs('Compose'), 'Business Analyst'),'899400000',if(equals(outputs('Compose'), 'Senior Business Analyst'),'899400001','0'))

In the expression to apply when the condition is false, you should add another if, and so on...

Regards,

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

This worked! Just what i was looking for - thank you 

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,044)