Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

I try to update a field by using a value range

(1) ShareShare
ReportReport
Posted on by 189

Hello 

I am trying to get a filed updated by value ranges:

 

/*
Update item in column ApproverGroup
*/
If(
    Value(TextInput2.Text) <= 2000,
    Patch(
        'NEW-BRAZIL-Main',
        LookUp(
            'NEW-BRAZIL-Main',
            myID = varID,
            {
                ApproverGroup: {Value: "NoApprover"}
            }
        ),
        If(
            Value(TextInput2.Text) <= 10000,
            Patch(
                'NEW-BRAZIL-Main',
                LookUp(
                    'NEW-BRAZIL-Main',
                    myID = varID,
                    {
                        ApproverGroup: {Value: "AccountManager"}
                    }
                ),
                If(
                    Value(TextInput2.Text) > 10000,
                    Patch(
                        'NEW-BRAZIL-Main',
                        LookUp(
                            'NEW-BRAZIL-Main',
                            myID = varID,
                            {
                                ApproverGroup: {Value: "Director"}
                            }
                        )
                    )
                )
            )
        )
    )
)
;
 
 
I tried also to get the sum of the Library field by using the code:
 
/*
Update item in column ApproverGroup
*/
If(
Sum(Gallery1.AllItems,ValorAjuste) <= 2000,
Patch(
'NEW-BRAZIL-Main',
LookUp(
'NEW-BRAZIL-Main',
myID = varID,
{
ApproverGroup: {Value: "NoApprover"}
}
),
If(
Sum(Gallery1.AllItems,ValorAjuste) <= 10000,
Patch(
'NEW-BRAZIL-Main',
LookUp(
'NEW-BRAZIL-Main',
myID = varID,
{
ApproverGroup: {Value: "AccountManager"}
}
),
If(
Sum(Gallery1.AllItems,ValorAjuste) > 10000,
Patch(
'NEW-BRAZIL-Main',
LookUp(
'NEW-BRAZIL-Main',
myID = varID,
{
ApproverGroup: {Value: "Director"}
}
)
)
)
)
)
)
)
;
 
 
The problem is, that the field is not updating the ApproverGroup.
Is there any idea available, I try to AVOID to use flow, which is more simple but not what I want to achieve...
 
Thanks in advance 😉
 
Cheers
Michael
  • MD2024 Profile Picture
    189 on at
    Re: I try to update a field by using a value range

    Hello FLMike

    It was not working for me with the Trace() as you told me: 

    Trace("<2000")' above the Value line
    Trace("<=10000") again above its sections valuel line


    I get no output with sense in the monitored trace.

    Or I dont get any output:

     

    onSelect  Button 

    -----------------------

    Set(varTest,"");
    If(

    Trace(<= 2000),
    Value(TextInput1.Text) <= 2000,
    Set(varTest,"smaller then 2000"),

    Trace(<= 10000),
    Value(TextInput1.Text) <= 10000,
    Set(varTest,"higher 2000 less + equal 10000"),

    Trace(> 10000),
    Value(TextInput1.Text) > 10000,
    Set(varTest,"higher then 10000")
    )

     

    And I like to see the variable value as well (with other debugger you can do)...,

    so not really working for me ;(

     

    Cheers

    Michael

  • MD2024 Profile Picture
    189 on at
    Re: I try to update a field by using a value range

    😁No, why I would do that... I replaced the old IF with a switch, thats how it works 👍

  • Michael E. Gernaey Profile Picture
    40,998 Super User 2025 Season 1 on at
    Re: I try to update a field by using a value range

    Thats a shame as it shouldn't take that long to test the scenarios and would have helped out to tell you exactly what was broken but hey go the long way, what do I know...... oh wait..

  • ivan_apps Profile Picture
    2,187 Super User 2025 Season 1 on at
    Re: I try to update a field by using a value range

    I’m confused, did you wrap your IF statement in a Switch with the only case being ‘true’ and it somehow started working??

  • MD2024 Profile Picture
    189 on at
    Re: I try to update a field by using a value range

    Hello ivan_apps

    Thanks for the hint, makes it easier 😉

     

    Cheers

    Michael

  • MD2024 Profile Picture
    189 on at
    Re: I try to update a field by using a value range

    Hello Michael

    Thanks for the Trace() information, thats helpful in some circumstances otherwise I needed to test every variation to find ou whats working or not.

    The trigger is a Button onSelect.

    My solution on the en which was working is a Switch()

     

     

    Switch(true,
    Value(TextInputSum.Text) <= 2000, //FIRST CONDITION
    Patch(InventoryAdjust_Main,LookUp(InventoryAdjust_Main,Identifier=DataCardValue24.Text),{ApproverGroup:{Value:"NoApprover"}});
    // Requester don#t need approval <= 2000
    Patch(InventoryAdjust_Main,LookUp(InventoryAdjust_Main,Identifier=DataCardValue24.Text),{Status:{Value:"Approved"}});
    
    Value(TextInputSum.Text) >2000 And Value(TextInputSum.Text) <=10000, //SECOND CONDITION
    Patch(InventoryAdjust_Main,LookUp(InventoryAdjust_Main,Identifier=DataCardValue24.Text),{ApproverGroup:{Value:"AccountManager"}});
    
    Value(TextInputSum.Text) >10000, //SECOND CONDITION
    Patch(InventoryAdjust_Main,LookUp(InventoryAdjust_Main,Identifier=DataCardValue24.Text),{ApproverGroup:{Value:"Director"}});
    );

     

     

    The idea with:   Sum(Gallery1.AllItems,ValorAjuste) was still not working.

     

    But thanks a lot for your hint !!!

    Cheers

    Michael

     

     

  • ivan_apps Profile Picture
    2,187 Super User 2025 Season 1 on at
    Re: I try to update a field by using a value range

    How are you defining "varID"?  that seems like the key to your issue, you're doing a lookup to it on all scenarios. Do your choice values also not have spaces in between? if it doesn't match what's configured, i believe sharepoint will create the new choice value for you, but your filters may be hard-coded with spaces like "No Approver".

     

    You also don't have to nest IF statements, you can simplify like this:

    If(
        Value(TextInput2.Text) <= 2000,
        Patch(),
        Value(TextInput2.Text) <= 10000,
        Patch(),
        Value(TextInput2.Text) > 10000,
        Patch(),
        [else condition]
    )
  • Michael E. Gernaey Profile Picture
    40,998 Super User 2025 Season 1 on at
    Re: I try to update a field by using a value range

    Can you please do me a favor @MD2024   and re-paste your code into Code Snipps </> so its easier to consume.

    And I am going to focus on the one question for the title.

     

    How is this code triggered? a button, onchange event what?

     

    You said it doesn't update, which I assume means it doesn't hit any of these If places.

    1. Does this happen in Dev, Test, Prod, all of the above?

     

    If it happens in dev then do this

    Above your If put

    Trace("Above If Statement - " & TextInput2.Text);
    
    This will tell you for 100% what its trying to do
    
    Now in each section of the if's add a Trace statement so see if it hits any of them
    
    Trace("<2000")' above the Value line
    Trace("<=10000") again above its sections valuel line
    
    Once you do this, if its in Dev, then hit the Stethescope and run Monitor.
    Repro the issue
    Go to the Monitor Tab in the Browser
    
    Type Trace for the filter
    see which ones get triggered,
    
    Should take 5 minutes tops.
    


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,635 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard