Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Query
Answered

Using ReplaceValue to conditionally replace a cell with a numeric value based on another column's value

(0) ShareShare
ReportReport
Posted on by 4

I've seen lots of suggestions for when one is populating cells with text, but what if the new value is a number?  In the example below, I filtered a table to a single row and requesting if the ticker column is "T", then put a number in the Total Cost column. 

 

I can't seem to get this to work.  Any guidance would be greatly appreciated.  

 

= Table.ReplaceValue(#"Filtered Rows1", each [Ticker], each if Text.Contains([Ticker],"T") then 5 else 3,Replacer.ReplaceValue,{"Total Cost"})

  • RonR Profile Picture
    8 on at
    Re: Using ReplaceValue to conditionally replace a cell with a numeric value based on another column's value

    I guess Microsoft and @Syndicate_Admin would rather obscure things than make it simple.

    If you look at the answers that @Syndicate_Admin posted, you will see they make a reference to a "Source Community". If you click on that link, you will find the forum where I actually answered this question. The real source of this answer 

  • Wolly Profile Picture
    4 on at
    Re: Using ReplaceValue to conditionally replace a cell with a numeric value based on another column's value

    RonR, I'm really confused as I don't see any other solution/suggestion other than the (x,y,z) solution...

  • RonR Profile Picture
    8 on at
    Re: Using ReplaceValue to conditionally replace a cell with a numeric value based on another column's value

    I don't know why @Syndicate_Admin seems to be taking credit for the answer I posted. If you go to the linked forum where I answered this question, you will see that I edited that answer to a correct one, and also explained the error in your original code (which was pretty close). What @Syndicate_Admin  copied here, although it works, should not be used as it is, in my opinion, bad programming technique. In the example that @Syndicate_Admin copied here, the null argument is irrelevant, as it never gets used; and the (x,y,z)=> refer to the three arguments normally passed to the Replacer.ReplaceValue function by the Table.ReplaceValue function. (See MS Help for that function for details).

  • Wolly Profile Picture
    4 on at
    Re: Using ReplaceValue to conditionally replace a cell with a numeric value based on another column's value

    Thank you Admin-  It worked!  Would you mind helping me understand how the code works with respect to "null" and  x,y,z variables?

     

    Much appreciated!

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Query

#1
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 7

#3
SD-13050734-0 Profile Picture

SD-13050734-0 6

Overall leaderboard

Featured topics