Formula with multiple statements

Formula with multiple statements

Teresa.KawaguchiGUSLM
Enthusiast Enthusiast
706 Views
10 Replies
Message 1 of 11

Formula with multiple statements

Teresa.KawaguchiGUSLM
Enthusiast
Enthusiast

The result I'm working for is: 

    If multiple lenses are selected (via yes/no lens formula), return the multiple lens error.

    If one lens is selected, return the detail number (1862-XXX).

    If no lens is selected, return the no lens error.

 

I'm trying to combine these two formulas: 

if(PTZ LENS, "1862-207", if(FIXED LENS, "1862-208", if(MULTI LENS, "1862-209", "ERROR-NO LENS SELECTED")))
if(PTZ LENS, FIXED LENS, if(PTZ LENS, MULTI LENS, if(FIXED LENS, MULTI LENS, "ERROR-MULTIPLE LENSES SELECTED)))

 

TeresaKawaguchiGUSLM_0-1652972474506.pngTeresaKawaguchiGUSLM_1-1652972504301.png

 

 

 

With this, I get unexpected end of expression 

if(and(PTZ LENS, FIXED LENS, if(PTZ LENS, MULTI LENS, if(FIXED LENS, MULTI LENS, "ERROR-MULTIPLE LENSES SELECTED"))), if(PTZ LENS, "1862-207", if(FIXED LENS, "1862-208", if(MULTI LENS, "1862-209", "ERROR-NO LENS SELECTED")))

 

 

Thanks for any help. 

 

 

Accepted solutions (2)
707 Views
10 Replies
Replies (10)
Message 2 of 11

ToanDN
Consultant
Consultant

I didn't have my morning coffee yet to fix the formula.  But why can't you create the Y/N and Detail Number as type parameters, and create 4 family types with proper combination of Y/N boxes ticked and Detail Number value pre-entered for each type?

0 Likes
Message 3 of 11

Teresa.KawaguchiGUSLM
Enthusiast
Enthusiast

The family types refer to the way the camera is mounted (ie Site Pole, Corner, Unistrut, Wall Flush, Pendant). There are seven mounting options. There are four camera lens options. Having a family with 28 types (one family type for each lens type for each mounting) seems a lot.

0 Likes
Message 4 of 11

lucdoucet_msdl
Advisor
Advisor

@Teresa.KawaguchiGUSLM 

 

You are mixing text and yes/no results in the two IF statement you are trying to combine:

 


I'm trying to combine these two formulas: 

if(PTZ LENS, "1862-207", if(FIXED LENS, "1862-208", if(MULTI LENS, "1862-209", "ERROR-NO LENS SELECTED")))

The first IF statement will return one of 4 text values which is OK.

 

if(PTZ LENS, FIXED LENS, if(PTZ LENS, MULTI LENS, if(FIXED LENS, MULTI LENS, "ERROR-MULTIPLE LENSES SELECTED)))

The second IF statement tries to return 3 yes/no values and 1 text value "ERROR-MULTIPLE LENSES SELECTED" which is not supported. It is also missing a " at the end of the "ERROR-MULTIPLE LENSES SELECTED".

 

Additionally, you will not be able to combine these two for the same reason as the second IF statement. You cannot mix text and yes/no results because the parameter receiving the result can only be one or the other type.

 

if(and(PTZ LENS, FIXED LENS, if(PTZ LENS, MULTI LENS, if(FIXED LENS, MULTI LENS, "ERROR-MULTIPLE LENSES SELECTED"))), if(PTZ LENS, "1862-207", if(FIXED LENS, "1862-208", if(MULTI LENS, "1862-209", "ERROR-NO LENS SELECTED")))

 

This third statement is also mixing text and yes/no types in the first part of the AND statement. The AND statement can only work with yes/no values. 

 

Hope this helps,

 

-luc

0 Likes
Message 5 of 11

ToanDN
Consultant
Consultant

@Teresa.KawaguchiGUSLM wrote:

The family types refer to the way the camera is mounted (ie Site Pole, Corner, Unistrut, Wall Flush, Pendant). There are seven mounting options. There are four camera lens options. Having a family with 28 types (one family type for each lens type for each mounting) seems a lot.


Here is the  syntax:

IF ( AND (x = 1 , y = 2), <true>, <false>)

<true> is the part where you can enter the value directly

<false> is the part where you keep extending the formula with further [if(and(...]

 

0 Likes
Message 6 of 11

Teresa.KawaguchiGUSLM
Enthusiast
Enthusiast

Can I add to this a trap for two lenses being selected? 

 

TeresaKawaguchiGUSLM_1-1652976121464.png

 

TeresaKawaguchiGUSLM_2-1652976173811.png

Something like   if(and(FIXED LENS, MULTI LENS, 99), if(and(FIXED LENS, PTZ LENS, 99)  

0 Likes
Message 7 of 11

lucdoucet_msdl
Advisor
Advisor
No, you are now mixing yes/no and numerical values in the AND statements.

-luc
0 Likes
Message 8 of 11

ToanDN
Consultant
Consultant
Accepted solution

IF (AND (P, NOT (F), NOT (M)), "1862-207", IF (AND (F, NOT (P), NOT (M)), "1862-208", IF (AND (M, NOT (F), NOT (P)), "1862-209", "ERROR")))

 

replace P, F, M with your parameters

 

ToanDN_0-1652976725245.png

 

ToanDN_1-1652976749480.png

 

ToanDN_2-1652976765978.png

 

ToanDN_3-1652976791720.png

 

ToanDN_4-1652976810445.png

 

ToanDN_5-1652976830558.png

 

ToanDN_6-1652976842589.png

 

ToanDN_7-1652976854482.png

 

 

 

 

 

 

 

 

 

 

0 Likes
Message 9 of 11

lucdoucet_msdl
Advisor
Advisor

@Teresa.KawaguchiGUSLM 


It seems to me that your are basically trying to tell the Revit user that they have to select at least one and no more than one yes/no parameter. I would suggest that you simply change the error message to say this "ERROR - NONE OR TOO MANY LENS OPTIONS SELECTED" or "ERROR - CHOOSE ONE AND ONLY ONE LENS OPTION IN THE PARAMETERS".

 

The if statement then becomes:

 

if(PTZ LENS, "1862-207", if(FIXED LENS, "1862-208", if(MULTI LENS, "1862-209", "ERROR-NONE OR TOO MANY LENS OPTIONS SELECTED")))

 

Sorry, didn't work but you could use @ToanDN formula and possibly extend it to give two distinct error messages this way:

IF (AND (P, NOT (F), NOT (M)), "1862-207", IF (AND (F, NOT (P), NOT (M)), "1862-208", IF (AND (M, NOT (F), NOT (P)), "1862-209", IF (AND(P,F,M),"ERROR1", "ERROR2"))))

 

ERROR1 = CHOOSE AT LEAST ONE LENS

ERROR2 = CHOOSE ONLY ONE LENS

 

Hope this helps;

 

-luc

0 Likes
Message 10 of 11

Teresa.KawaguchiGUSLM
Enthusiast
Enthusiast

Thank you!

0 Likes
Message 11 of 11

Teresa.KawaguchiGUSLM
Enthusiast
Enthusiast
Accepted solution

This is the solution I needed. 

Much appreciation for your help in getting here. 

TeresaKawaguchiGUSLM_0-1652982453434.png

 

0 Likes