Select to view content in your preferred language

IF Statement Priority Dependency Cycle

823
6
Jump to solution
01-02-2024 02:12 PM
Adam_Bourque
Regular Contributor

Hello all,

Is it possible to use two different fields to generate values and have one field be priority / overwrite? 

I am using an IF statement that looks at two previous fields to determine if water service line needs replaced based on bothsidestatus. That part works fine; however, I am wanting the "length(${scheddate}>0 Scheduled Replacement" to overwrite / or take priority over the bothsidestatus. 

In better words, if the user schedules a replacement date in either utility or customer side with this schedule date field, I want the calculation to show the status as "Scheduled Replacement" rather than "Still Identifying Material Types / Needs Replaced / Doesn't Need Replaced" options. I tried to move the string-length option to the front of the calculation but kept getting the error "If statement needs 3 conditions, and you only have 1 condition". 

Calculation:

if(${bothsidesstatus}='Unknown' , "Still Identifying Material Types", if(${bothsidesstatus}='Non-Lead' , "Doesn't Need Replacement", if(${bothsidesstatus}='Galvanized Requiring Replacement', "Needs Replacement", if(${bothsidesstatus}='Lead', "Needs Replacement", if(string-length(${custscheddate}>0 or if(string-length(${scheddate}>0, "Scheduled Replacement", "Still Identifying Material Types"))))))))

 

Thank you, if you need a copy of my survey or anything else please let me know

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

You have some syntax errors still here.  Its string-length() you are missing the )  Lets try

if(string-length(${custscheddate}) > 0 or string-length(${scheddate}) > 0, "Scheduled Replacement", if(${bothsidesstatus}='Unknown' , "Still Identifying Material Types", if(${bothsidesstatus}='Non-Lead' , "Doesn't Need Replacement", if(${bothsidesstatus}='Galvanized Requiring Replacement', "Needs Replacement", if(${bothsidesstatus}='Lead', "Needs Replacement", "Still Identifying Material Types")))))

View solution in original post

6 Replies
DougBrowning
MVP Esteemed Contributor

This part here you would not have two if statements the or will be enough.

if(string-length(${custscheddate}>0 or if(string-length(${scheddate}>0,

Change to 

if(string-length(${custscheddate}>0 or string-length(${scheddate}>0,

0 Kudos
Adam_Bourque
Regular Contributor

Awesome @DougBrowning you definitely solved that part of my situation, true MVP; however, the code still prioritizes the Unknown - Still identifying materials option because it is first in the equation. When I try to put the string length cust schedule date option first like here I still get the "Only 1 provided of 3 statements S123". If I put it last in the order like my existing code with the fixed code, still does not "overwrite" prioritize which I guess makes sense given the order. Not sure why it is still being picky at the code below, any additional work around? Maybe I will need to implement a repeat field or something if this doesn't work.

 

Thank you for spending the time to help us out here at the forums.

if(string-length(${custscheddate}>0 or string-length(${scheddate}>0, "Scheduled Replacement", if(${bothsidesstatus}='Unknown' , "Still Identifying Material Types", if(${bothsidesstatus}='Non-Lead' , "Doesn't Need Replacement", if(${bothsidesstatus}='Galvanized Requiring Replacement', "Needs Replacement", if(${bothsidesstatus}='Lead', "Needs Replacement", "Still Identifying Material Types")))))))

0 Kudos
DougBrowning
MVP Esteemed Contributor

You have some syntax errors still here.  Its string-length() you are missing the )  Lets try

if(string-length(${custscheddate}) > 0 or string-length(${scheddate}) > 0, "Scheduled Replacement", if(${bothsidesstatus}='Unknown' , "Still Identifying Material Types", if(${bothsidesstatus}='Non-Lead' , "Doesn't Need Replacement", if(${bothsidesstatus}='Galvanized Requiring Replacement', "Needs Replacement", if(${bothsidesstatus}='Lead', "Needs Replacement", "Still Identifying Material Types")))))

Adam_Bourque
Regular Contributor

Thank you so much @DougBrowning I thought about the syntax / putting parenthesis bracket, but have been spoiled at always putting them at the very end. This opens up more avenues for surveys, 😁

0 Kudos
Adam_Bourque
Regular Contributor

Last question in regards to this, is it possible to have the calculation overwrite / update without having to use the refresh button? I am using "autocomplete" but I am opening this survey via inbox method which I think might have something to do with it. It's not the end of the world to have to click the refresh button occasionally, but was curious if you knew any fixes to this.

 

Adam_Bourque_0-1704302283120.png

 

0 Kudos
DougBrowning
MVP Esteemed Contributor

If from Inbox then no since it counts as you editing.