Ever wondered how to use if condition logic when you’re creating custom formulas or ratios on Screener.in?
For example, imagine you want something like this:
If Profit is greater than 50%, then calculate Profit multiplied by 70%. Otherwise, calculate Profit multiplied by 20%.
It sounds like you’d need some complicated programming syntax or a special function, right? Actually, it’s far simpler than most people expect. Screener uses a very old and clever trick in condition logic that this generation is often not even aware of.
The Core Idea: Boolean Multiplication
Here’s how it works. In Screener, any condition you write will automatically evaluate to either 1 or 0:
- If the condition is true, it becomes 1.
- If the condition is false, it becomes 0.
Because of this, you can build what looks like an if-else directly in one formula. Here’s the pattern:
(Profit > 50%) * (Profit * 70%) + (Profit <= 50%) * (Profit * 20%)
Let’s break down what’s happening here:
- If Profit is actually greater than 50%, the part (Profit > 50%) evaluates to 1, and (Profit <= 50%) evaluates to 0.
- So, this turns the formula into:
1 * (Profit * 70%) + 0 * (Profit * 20%)
In other words, only the part you want is activated, and the other part disappears.
Conversely, if Profit is 40%, then (Profit > 50%) becomes 0, and (Profit <= 50%) becomes 1, so you get:
0 * (Profit * 70%) + 1 * (Profit * 20%)
Effectively, you get exactly what you desire: one formula that behaves like an if-else without any extra functions.
Why This Still Works So Well
This technique is called Boolean multiplication. It’s been around for decades in programming and mathematics. Even though it looks almost too simple, it remains one of the most reliable ways to express conditional logic when your formula system doesn’t support direct if-else statements.
So the next time you want to apply different calculations based on thresholds in Screener, just remember:
(Condition1) * (ValueIfTrue) + (Condition2) * (ValueIfFalse)
That’s it. No special tricks, no advanced coding—just clean, old-school logic doing exactly what you need.