Hi Mischa,
Could possibly be a bug, or just a very confused automatic type conversion, not sure. Then again, it could also be 'logical' but I'm leaning towards "bug" myself...
I'm not sure why it does this, but after playing with it a bit I have a theory...see the following tests;
Based on the If() construct - If(logical test, true_value, else_value)
If(true, true, false)
1. The logical check = true, the result is the true_value which is true.
If(false, true, false)
2. The locial check = false, the result is the else_value which is false
If(true, true, "sometext")
3. The logical check = true, the result is the true_value which is true.
If(false, true, "sometext")
4. The logical check = false, the result is the else value which should be "sometext" but comes back as false
Here's what I think is happening - when the true_value is a boolean type, PowerApps for some reason is converting the else_value to a boolean type as well and returning the result. If the result is not explicitly boolean true, it's false.
In the above, "sometext" is not equal to true, therefore the result is false.
Confused yet? Try this;
If(false, true, 0) result false
If(false, true, 1) result true
If(false, true, "true") result true
If(false, true, "True") result false
0 can be logically auto-converted to boolean as false - anything greater than 0 is true.
"true" can be auto-converted to boolean as true - anything else is false.
This only seems to become apparent when;
The result of the logical check is false AND the true_value is a boolean.
So I'll go with "bug" for now unless someone else has any logical reason why this should be so 🙂
By the way, if you need your example to work, as a workaround you can just change the type of the true_value to a string - so;
If(Toggle1.TrueText="On", Text(Toggle1.Value), "")
Kind regards,
RT