Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

if function with 3 clauses

felix_wfelix_w Member Posts: 61 Contributor II
edited November 2018 in Help

Dear Rapidminer Community, 

 

I would like to build an if function via generate attributes but I have a problem because I have more than two "answers" to my if clause. 

 

What I tried to build is this (look at the bottom) but it didn't work because the "||" operator expects a numeric or boolean type which I dont have, I have real. Furthermore, I can't fit all the clauses in one if statement right? Because I have 3 options to fulfill: 

if Storage <3% --> 40% pull

if Storage >= 51% --> 100% pull

if Storage >=3% && <=50% --> 60% pull 

 

Is there any possibilty to solve this?

 

(if([Füllstand]<=0.02, 0.4*Einlagerleistung, "")) ||
(if([Füllstand]>=0.51, Einlagerleistung, "")) ||
(if([Füllstand]>=0.03 && [Füllstand]<=0.5, 0.6*Einlagerleistung, ""))

 

I hope it's clear what I want to do. ;) 

 

Best regards

Felix

Best Answer

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Solution Accepted

     

    Hi,

     

    it's usually easier to nest the if()s.

     

    if([Füllstand] <= 0.02, 0.4 * Einlagerleistung, 

        if([Füllstand] >= 0.51, Einlagerleistung, 

            0.6 * Einlagerleistung

        )

    )

     

    Regards,

    Balázs

Answers

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,531 RM Data Scientist

    Hi,

    the usual way i build this is:

    if( STORAGE < 3,
    "40% PULL",
    if( STORAGE > 51,
    "100% PULL" ,
    "50-60% PULL"
    )
    )

     

    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • felix_wfelix_w Member Posts: 61 Contributor II

    Thank you very much for your quick replies! Both of your solutions worked for me! :D 

     

    Best regards

    Felix

Sign In or Register to comment.