web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / NESTED IF STATEMENTS I...
Power Automate
Answered

NESTED IF STATEMENTS IN A FUNCTION

(0) ShareShare
ReportReport
Posted on by 33
Hi, I'm trying to create a flow that uses AI to extract a code from a document then adds the details to a sharepoint list. The code is made of a Letter and a number the Letter sets it as a Category and the number sets it to a Area.

I tried to do this with nested if statements but it just gives me an error. is there a better more efficient way to do this? There are a lot of code variations so my nested if looked like this and it was even larger for the Area being recognised off a number. I have 49 numbers in the code sequence. I also worry that if i was using the below for the numbers then it would mix up when trying to recognise 1 for 10,11 etc.
 
Any better ways to do this would be really appreciated.

Thanks
James

if(contains(variables('Budget_Code'), 'A'), 'COLUMNS',
if(contains(variables('Budget_Code'), 'B'), 'STRIP FOOTINGS',
if(contains(variables('Budget_Code'), 'C'), 'LIFT PAD',
if(contains(variables('Budget_Code'), 'D'), 'FOOTINGS',
if(contains(variables('Budget_Code'), 'E'), 'NON PT SLABS',
if(contains(variables('Budget_Code'), 'F'), 'SHEAR WALL',
if(contains(variables('Budget_Code'), 'G'), 'CORE WALLS',
if(contains(variables('Budget_Code'), 'H'), 'BUTTRESS WALLS',
if(contains(variables('Budget_Code'), 'I'), 'STAIRS',
if(contains(variables('Budget_Code'), 'J'), 'UPSTANDS',
if(contains(variables('Budget_Code'), 'K'), 'HOBS',
if(contains(variables('Budget_Code'), 'L'), 'MISCELLANEOUS',
if(contains(variables('Budget_Code'), 'M'), 'SUSPENDED PT SLAB WITH BEAMS',
if(contains(variables('Budget_Code'), 'N'), 'PT DIAPHRAGM',
if(contains(variables('Budget_Code'), 'O'), 'NON PT SLABS (COMPOSITE/BONDEC)',
if(contains(variables('Budget_Code'), 'P'), 'SAFETY MESH (SL82)',
'MISC')))))))))))))))))
Categories:
I have the same question (0)
  • Ellis Karim Profile Picture
    11,695 Super User 2025 Season 2 on at
    Can you provide some sample data for the budget code, so we can determine the patter for the category and area
     
    This will help determine a possible solution.
     
    Ellis
     
  • jpdamd Profile Picture
    33 on at
    Thanks Ellis,

    Yep my Budget code ranges from A1 to P49. See below. in the screen shot you can see that the number 1 in the code reflects Level or Area 'RAFT SLAB' while A is for the Category 'COLUMNS'
    The number 2 in the code would be for area B4, etc

  • Verified answer
    Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
    Like mentioned by EKarim it would be great to get some sample data to determine a pattern.
     
    In the past I have also used a mapping array for this. So, this might work for you as well. You can create a array with the letter/category mapping and use a filter array action to find the matching item based on the budget_code variable value.
     
    Below is an example of that approach.
     
    1. The filter in the Filter Array
    @contains(variables('Budget_Code'), item()['Letter'])
     
     
    2. The expression to return the category of the matching letter
     
    first(body('Filter_Array'))['category']
     
    A test result.
     
  • jpdamd Profile Picture
    33 on at
    Thanks guys, that has worked perfectly to pull through the Category. Struggling a bit to get it to work with my Level though. Below is the array I've created. my budget codes are all 2 to 3 digits in the below format

    A1
    C10
    D15
    This is how they appear within the BUDGET CODE variable. So the first Category array is working and recognising the letter and assigning the Category. How can i do the same but get it to look at the number and then return from my array below? 

    Thanks so much 

    [
    {
    "Number": 1,
    "Level": "RAFT SLAB"
    },
    {
    "Number": 2,
    "Level": "B4"
    },
    {
    "Number": 3,
    "Level": "B3"
    },
    {
    "Number": 4,
    "Level": "B2"
    },
    {
    "Number": 5,
    "Level": "B1"
    },
    {
    "Number": 6,
    "Level": "GF"
    },
    {
    "Number": 7,
    "Level": "UGF"
    },
    {
    "Number": 8,
    "Level": "L1"
    },
    {
    "Number": 9,
    "Level": "L2"
    },
    {
    "Number": 10,
    "Level": "L3"
    },
    {
    "Number": 11,
    "Level": "L4"
    },
    {
    "Number": 12,
    "Level": "L5"
    },
    {
    "Number": 13,
    "Level": "L6"
    },
    {
    "Number": 14,
    "Level": "L6M"
    },
    {
    "Number": 15,
    "Level": "L7"
    },
    {
    "Number": 16,
    "Level": "L8"
    },
    {
    "Number": 17,
    "Level": "L9"
    },
    {
    "Number": 18,
    "Level": "L10"
    },
    {
    "Number": 19,
    "Level": "L11"
    },
    {
    "Number": 20,
    "Level": "L12"
    },
    {
    "Number": 21,
    "Level": "L13"
    },
    {
    "Number": 22,
    "Level": "L14"
    },
    {
    "Number": 23,
    "Level": "L15"
    },
    {
    "Number": 24,
    "Level": "L16"
    },
    {
    "Number": 25,
    "Level": "L17"
    },
    {
    "Number": 26,
    "Level": "L18"
    },
    {
    "Number": 27,
    "Level": "L19"
    },
    {
    "Number": 28,
    "Level": "L20"
    },
    {
    "Number": 29,
    "Level": "L21"
    },
    {
    "Number": 30,
    "Level": "L22"
    },
    {
    "Number": 31,
    "Level": "L23"
    },
    {
    "Number": 32,
    "Level": "L24"
    },
    {
    "Number": 33,
    "Level": "L25"
    },
    {
    "Number": 34,
    "Level": "L26"
    },
    {
    "Number": 35,
    "Level": "L27"
    },
    {
    "Number": 36,
    "Level": "L28"
    },
    {
    "Number": 37,
    "Level": "L29"
    },
    {
    "Number": 38,
    "Level": "L30"
    },
    {
    "Number": 39,
    "Level": "L32"
    },
    {
    "Number": 40,
    "Level": "L33"
    },
    {
    "Number": 41,
    "Level": "L34"
    },
    {
    "Number": 42,
    "Level": "L35"
    },
    {
    "Number": 43,
    "Level": "L36"
    },
    {
    "Number": 44,
    "Level": "L37"
    },
    {
    "Number": 45,
    "Level": "L38"
    },
    {
    "Number": 46,
    "Level": "L39"
    },
    {
    "Number": 47,
    "Level": "ROOF"
    }
    ]

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 478 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 247 Moderator

#3
abm abm Profile Picture

abm abm 231 Most Valuable Professional

Last 30 days Overall leaderboard