The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

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, 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, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 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.