Project data & BIM
About BIM-based management of attributes, schedules, templates, favorites, hotlinks, projects in general, quality assurance, etc.
SOLVED!

Expressions with 2 logical conditions?

Jeff Galbraith
Advocate

image.jpeg

 

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

Jeff G

Archicad 27 USA (full), Macbook Pro (16-inch 2023, M3 MAX, 128 GB RAM)
1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Hi @Jeff Galbraith 

 

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 ) ) ) ) ) )

 

RicardoLopez_0-1716323339439.png

 

M. Arch. Ricardo López
BIM Consultant | Project Solutions and Services | Panama
AC17-28 SPA+INT | Windows 11 | MSI CreatorPro M16 HX C14VJG, 64GB, Nvidia Quadro RTX 2000 Ada Generation

View solution in original post

10 REPLIES 10
Xandros
Advisor

Yes, it's possible

IFS(AND(PropertyA="X"; PropertyB ="Z");"Y")
IF(AND(PropertyA="X"; PropertyB ="Z");"Y";"-")

 

ArchiCAD 27 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti

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?

Jeff G

Archicad 27 USA (full), Macbook Pro (16-inch 2023, M3 MAX, 128 GB RAM)

Two different ways depending on your desire to IF or IFS

ArchiCAD 27 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti

JeffGalbraith_0-1716307116648.png

JeffGalbraith_1-1716307204359.png

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?

Jeff G

Archicad 27 USA (full), Macbook Pro (16-inch 2023, M3 MAX, 128 GB RAM)

Hi @Jeff Galbraith 

 

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 )

RicardoLopez_3-1716316758805.png

 

 

RicardoLopez_2-1716316491102.png

 

 

 

M. Arch. Ricardo López
BIM Consultant | Project Solutions and Services | Panama
AC17-28 SPA+INT | Windows 11 | MSI CreatorPro M16 HX C14VJG, 64GB, Nvidia Quadro RTX 2000 Ada Generation

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.  

 

JeffGalbraith_0-1716318575171.png

 

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.

Jeff G

Archicad 27 USA (full), Macbook Pro (16-inch 2023, M3 MAX, 128 GB RAM)
Solution

Hi @Jeff Galbraith 

 

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 ) ) ) ) ) )

 

RicardoLopez_0-1716323339439.png

 

M. Arch. Ricardo López
BIM Consultant | Project Solutions and Services | Panama
AC17-28 SPA+INT | Windows 11 | MSI CreatorPro M16 HX C14VJG, 64GB, Nvidia Quadro RTX 2000 Ada Generation

It works!!!!  You sir, are a genius.  Thank you Ricardo!!!!

Jeff G

Archicad 27 USA (full), Macbook Pro (16-inch 2023, M3 MAX, 128 GB RAM)
furtonb
Advisor

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.

 

 

odv.hu | actively using: AC25-27 INT | Rhino6-8 | macOS @ apple silicon / win10 x64

Setup info provided by author