Skip to main content

Notifications

Power Automate - Building Flows
Answered

Select function, how to add if functions to my items?

Posted on by 17
Hi,
 
I'm still quite new to power automate and expressions in general, so this may be an easy question.
 
I'm trying to use the Select action to make a new array out of my existing array. This I could manage by using the correct item() function, based on the property name that I need. My problem comes when i only want a certain key filled if a condition is met.
 
In this example I'm trying to get some data out of system. For ease of understandig the data is 'ProjectResponsible', 'ProjectType' and 'Price'. My keys are 'Title' and then the differenct project types. Since title corresponds to 'ProjectResponsible' it's easy to get out dynamically. The tricky part is the different project types. My end goal is that I want the 'Price' of the given 'ProjectType' if the 'ProjectType' matches the name in the key of my select function.
 
I know that the if() expression needs a boolean value to determine the results, but is there another way to accomplish what I'm trying to do?
 
I hope it makes sense, and that someone can help make sense of it for me :)
 
  • Verified answer
    MH-05110755-0 Profile Picture
    MH-05110755-0 17 on at
    Select function, how to add if functions to my items?
    Hi,
     
    I just wanted to say that I found the solution.
     
    if(equals(item()?['ProjectType'],'Enterprise'),item()?['Price'],'')
     
    Compared to my original attempt
     
    if(item()?['ProjectType'], 'Enterprise', item()?['Price'], "-")
     
    The difference is the use of quotes. It's very important to use single quotes when declaring strings. So to anyone new to power apps, and Power Fx in particular, remember this :)
  • MH-05110755-0 Profile Picture
    MH-05110755-0 17 on at
    Select function, how to add if functions to my items?
    Hi CA1105,
     
    Of course. What i tried to do was:
     
    if(item()?['ProjectType'], 'Enterprise', item()?['Price'], "-")
     
    This didn't work which, I'm guessing, is because the if expression uses boolean values and I have provided none.
     
    What I specifically want, it for the expression to output the property 'Price' if the project type matches corresponding key i.e if the type is enterprise, it would output the price in under the enterprise key, and leave the other keys blank
     
    Title : Project Responsible
    Enterprise : 'Price'
    Service : N/A
    XX : N/A
    and so on
     
    Hope it clarifies it :)
  • CA1105 Profile Picture
    CA1105 222 on at
    Select function, how to add if functions to my items?
    Would you pls share your code what you have done so far and what you want to achieve in more details pls? It is hard to understand wihtout seeing this in action or may be throw one example to understand this.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard