We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2024-05-20 02:07 AM - last edited on 2024-05-23 05:59 PM by Laszlo Nagy
Is it possible to create an expression that derives a value based on the combination of 2 separate properties? I've been able to use the IF and IFS functions with varying success, but they both only appear to allow the use of one logical condition per result.
ie: The IF and IFS functions allow you to say: 'IF property A = "X", then use value "y".
What I'm looking for is something that says: 'IF property A = "X", AND property B = "Z", then use value "y".
I'm trying to recreate the function of a table with 2 axis, similar to the image above. The resulting value is based on the combination of 2 other properties. Is this possible with Expressions?
Operating system used: Mac Apple Silicon 14.5 Sonoma
Solved! Go to Solution.
2024-05-21 10:30 PM - last edited on 2024-05-23 06:00 PM by Laszlo Nagy
Then let's try just a nested expression with IF and IFS. It is quite boring but it could work:
IF ( {Property:ZONES/GIL} = 150; IFS ( {Property:ZONES/RCR} <= 2; 0.35; {Property:ZONES/RCR} <= 3.5; 0.4; {Property:ZONES/RCR} <= 7; 0.5; {Property:ZONES/RCR} > 7; 0.65 ); IF ( {Property:ZONES/GIL} = 200; IFS ( {Property:ZONES/RCR} <= 2; 0.4; {Property:ZONES/RCR} <= 3.5; 0.5; {Property:ZONES/RCR} <= 7; 0.65; {Property:ZONES/RCR} > 7; 0.85 ); IF ( {Property:ZONES/GIL} = 300; IFS ( {Property:ZONES/RCR} <= 2; 0.55; {Property:ZONES/RCR} <= 3.5; 0.7; {Property:ZONES/RCR} <= 7; 0.85; {Property:ZONES/RCR} > 7; 1.20 ); IF ( {Property:ZONES/GIL} = 400; IFS ( {Property:ZONES/RCR} <= 2; 0.65; {Property:ZONES/RCR} <= 3.5; 0.8; {Property:ZONES/RCR} <= 7; 1.05; {Property:ZONES/RCR} > 7; 1.25 ); IF ( {Property:ZONES/GIL} = 500; IFS ( {Property:ZONES/RCR} <= 2; 0.80; {Property:ZONES/RCR} <= 3.5; 0.9; {Property:ZONES/RCR} <= 7; 1.25; {Property:ZONES/RCR} > 7; 1.55 ); IF ( {Property:ZONES/GIL} = 600; IFS ( {Property:ZONES/RCR} <= 2; 0.9; {Property:ZONES/RCR} <= 3.5; 1.05; {Property:ZONES/RCR} <= 7; 1.4; {Property:ZONES/RCR} > 7; 2 ); 0 ) ) ) ) ) )
2024-05-21 09:47 AM
Yes, it's possible
IFS(AND(PropertyA="X"; PropertyB ="Z");"Y")
IF(AND(PropertyA="X"; PropertyB ="Z");"Y";"-")
2024-05-21 04:29 PM
Thanks Xandros, I will give that a try. Just to confirm, are you showing 2 different ways to achieve this, or do I need to use both the IFS and the IF expressions simultaneously?
2024-05-21 04:58 PM
Two different ways depending on your desire to IF or IFS
2024-05-21 06:02 PM
I've entered the IFS expressions but I'm not getting any results. The one item with the 1.25 in the right hand column was entered manually. Three of the other items in the schedule should be pulling the same number 1.25 from the expressions since the LUX target is 500 for all three, and the Room Cavity Ratio for all three is less than 7, but more than 3.5.
Any Idea what I might be missing here?
2024-05-21 08:37 PM - last edited on 2024-05-23 06:02 PM by Laszlo Nagy
I think it is a combination of both IF with a nested IFS.
Let's see the example made for zones only with the expression for the value of GIL=500, although the rest of the expressions for the different values of global illuminance levels (150,200,300, etc) should be added.
IF ( {Property:ZONES/GIL} = 500; IFS ( {Property:ZONES/RCR} <= 2; 0.8; {Property:ZONES/RCR} <= 3.5; 0.9; {Property:ZONES/RCR} <= 7; 1.25; {Property:ZONES/RCR} > 7; 1.55 ); 0 )
2024-05-21 09:12 PM
Thanks Ricardo, that seems to work for one row of the table. I assumed I would then need to write a new expression clause for each row of the table, However since the IF expression returns a 0 if none of the first expression clause criteria are met, it does not move onto the next expression clause, it just uses the 0.
When I rewrite the first expression clause using IFS instead of IF, it returns 'undefined' but then appears to not go on to the next expression clause. See below.
How do I get archicad to move on from the first clause to subsequent clauses if the conditions from the first clause are not met? I expected that to be automatic based on what I've read elsewhere.
2024-05-21 10:30 PM - last edited on 2024-05-23 06:00 PM by Laszlo Nagy
Then let's try just a nested expression with IF and IFS. It is quite boring but it could work:
IF ( {Property:ZONES/GIL} = 150; IFS ( {Property:ZONES/RCR} <= 2; 0.35; {Property:ZONES/RCR} <= 3.5; 0.4; {Property:ZONES/RCR} <= 7; 0.5; {Property:ZONES/RCR} > 7; 0.65 ); IF ( {Property:ZONES/GIL} = 200; IFS ( {Property:ZONES/RCR} <= 2; 0.4; {Property:ZONES/RCR} <= 3.5; 0.5; {Property:ZONES/RCR} <= 7; 0.65; {Property:ZONES/RCR} > 7; 0.85 ); IF ( {Property:ZONES/GIL} = 300; IFS ( {Property:ZONES/RCR} <= 2; 0.55; {Property:ZONES/RCR} <= 3.5; 0.7; {Property:ZONES/RCR} <= 7; 0.85; {Property:ZONES/RCR} > 7; 1.20 ); IF ( {Property:ZONES/GIL} = 400; IFS ( {Property:ZONES/RCR} <= 2; 0.65; {Property:ZONES/RCR} <= 3.5; 0.8; {Property:ZONES/RCR} <= 7; 1.05; {Property:ZONES/RCR} > 7; 1.25 ); IF ( {Property:ZONES/GIL} = 500; IFS ( {Property:ZONES/RCR} <= 2; 0.80; {Property:ZONES/RCR} <= 3.5; 0.9; {Property:ZONES/RCR} <= 7; 1.25; {Property:ZONES/RCR} > 7; 1.55 ); IF ( {Property:ZONES/GIL} = 600; IFS ( {Property:ZONES/RCR} <= 2; 0.9; {Property:ZONES/RCR} <= 3.5; 1.05; {Property:ZONES/RCR} <= 7; 1.4; {Property:ZONES/RCR} > 7; 2 ); 0 ) ) ) ) ) )
2024-05-21 10:41 PM
It works!!!! You sir, are a genius. Thank you Ricardo!!!!
2024-05-21 11:01 PM
Lovely expression, it reminded me of some things that should be improved:
- keeping the line breaks (you test something, apply the changes, and the neatly structured code breaks again into a single wall of text – why?)
- syntax higlighting
- commenting
Without these, there could be some cases when you are in the flow while creating the expression, fully understanding what goes where and how the logical steps are layered...:)
...then something needs changing a month later and you are just staring at the screen in disbelief for minutes, because you need to untangle the mess again.