• Resolved obamoose

    (@obamoose)


    Hi

    I want to create a lookup table inside a single calculated field where I fill in fieldname21 and if it isn’t equal it shows me ‘WRONG’.

    (function(){
    IF(fieldname21 == 8787879879788, '€195.28', 'fieldname23');
    IF(fieldname21 == 8787879879789, '€555,55', 'fieldname23');
    IF(fieldname21 == 8787879879790, '€188,40', 'fieldname23');
    IF(fieldname21 == 8787879879791, '€120,94', 'fieldname23');
    })(); 

    Is this the right way of doing it?

    Thanks in advance!

    Greetings,
    Obamoose

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @obamoose

    No, your equation is not right. If you implement an equation with function structure, you need to use the return instruction to return the equation’s result. In your equation the solution would be use the if conditional statement of javascript (Javascript is a case sensitive language, please, do not confuse the conditional statement if with the operation IF in the plugin):

    
    (function(){
    if(fieldname21 == 8787879879788) return '€195.28';
    if(fieldname21 == 8787879879789) return '€555,55';
    if(fieldname21 == 8787879879790) return '€188,40';
    if(fieldname21 == 8787879879791) return '€120,94';
    
    return fieldname23;
    })(); 
    

    Another alternative, even better, would be use the switch conditional statement, as follows:

    
    (function(){
    switch(fieldname21)
    {
    case 8787879879788: return '€195.28';
    case 8787879879789: return '€555,55';
    case 8787879879790: return '€188,40';
    case 8787879879791: return '€120,94';
    default: return fieldname23;
    }
    })(); 
    

    Best regards.

    Thread Starter obamoose

    (@obamoose)

    Thanks, dude!

    You’re a hero!

    Hey, sorry to hijack someone else’s thread, but I’m trying to do something similar with text but I can’t get it to work. Does anyone have any ideas of how to do something where the fieldname is; DE, NG, LE etc & a value can be returned in the other field?

    I tried

    (function(){
    switch(fieldname1)
    {
    case DE: return ‘€195.28’;
    case NG: return ‘€555,55’;
    case LE: return ‘€188,40’;
    case S: return ‘€120,94’;
    default: return fieldname3;
    }
    })();

    but it doesn’t work

    Thanks

    Plugin Author codepeople

    (@codepeople)

    Hello @peekocharlie

    In javascript, the text values must be enclosed between single or double quotes, so, your equation should be edited as follows:

    
    (function(){
    switch(fieldname1)
    {
    case 'DE': return '€195.28';
    case 'NG': return '€555,55';
    case 'LE': return '€188,40';
    case 'S': return '€120,94';
    default: return fieldname3;
    }
    })();
    

    Best regards.

    Hello,

    When client is logged in and if his email is in the csv file then the calculation of de price changes.

    How to compare login email with a csv file(with emails) so the calculated field returns another price.

    Fatih

    Plugin Author codepeople

    (@codepeople)

    Hello @fatih71

    We’d like to help but we can’t reply about that in this forum. We are not allowed to support any customers in these forums.

    For pro or commercial product support please contact us directly on our site. This includes any pre-sales topics as well.

    Commercial products are not supported in these forums. We will happily answer this and any other questions you can have on our own site.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Lookup table.’ is closed to new replies.