Forum Discussion
how do you manipulate an individual cell value using an IF conditional
I would like to modify a cell value between its current value and 0 if another cell has a conditioning value in it.
let's say the conditioning value = T and the target cell value = 34. If the conditioning cell value = T then the displayed target cell value = 0. If the conditioning cell value = F, then the current target cell value remains unchanged.
That's good, if your scenario is so simple, GDW11 . Then... please mark NikolinoDE 's post as answer (:
4 Replies
- g0ldfinchCopper Contributor
GDW11 Your requirements are incomplete. You say that if the conditioning value is T, then the target value becomes 0, and if the conditioning value is F, then the value remains unchanged. What about blank conditioning values? Other letters? Because the response by NikolinoDE assumes your conditioning column is fully populated with T or F, no blanks. Also he assumed that your conditioning column is A, actual value is column B, and you put your formula in a separate column called target. This may not be a correct assumption because it seems you want to modify the target cell rather than show a value conditionally in a separate column. In this case, you should convert your excel range to a table and create a PowerQuery object from that table. Then select your column, choose "Replace Value", enter any source/target value, after which you adjust the generated formula with something like:
= Table.ReplaceValue(#"Changed Type",each [target_column],each if [condition_column] = "F" then 0 else [target_column],Replacer.ReplaceValue,{"target_column"})Of course, without knowing the requirements, and why you need this, it's difficult to answer your question. However, you have 2 options: go with a simple Excel formula and have an extra column, or create a PowerQuery table and transform the data inside PQ. If your requirement is the only requirement, I would suggest to go with the simple Excel formula. If you have more complex requirements, you may not be able to implement them via formulas, in which case you should go with the PowerQuery.
Hope that helps.
- GDW11Copper Contributor
For single line modification, the if works just fine. What I forgot to mention is that I am using a template and I was hoping that the if conditional could work using it in the template. My format rules in the template are properly executed when using the template.
- g0ldfinchCopper Contributor
That's good, if your scenario is so simple, GDW11 . Then... please mark NikolinoDE 's post as answer (:
- NikolinoDEPlatinum Contributor
=IF(A1="T", 0, B1)
This formula checks if the value in cell A1 is "T." If it is, the formula returns 0; otherwise, it returns the current value in cell B1.
Hope this will help you.