Options

Creating a Variable

amotleyamotley Member Posts: 17 Contributor II
edited November 2018 in Help

In one of my processes, I use the aggregate operator to add up all the footage of all the rows in my data set. Once I have this, I am trying to calculate the percentage of each row's footage to this total footage. I am using the generate attribute operator for this, and have FOOTAGE/#. # represents the total footage calculated  in the aggregate step that I have to manually put in to that function. 

 

Is there a way I can assign the total footage to a variable that I can pull back into that function later? I would like to do this so I do not have to manually enter in the total footage number everytime fo reach row. 

 

Thank you!

Answers

  • Options
    yyhuangyyhuang Administrator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 364 RM Data Scientist

    Hi Amotley,

     

    Have you tried to 'Extract Macro' in your process? You can

    (1) aggregate and find total footage

    (2) extract total footage and keep it in a macro %{TOT_FOOTAGE}

    to do this, you may set macro as 'TOT_FOOTAGE', macro type as 'data_value' and example index as 1 in 'extract macro' operator

    (3) use 'generate attribute' to add a new attribute, say attributed named percentage and its function expression could be FOOTAGE/%{TOT_FOOTAGE}, then each row's footage devided by %{TOT_FOOTAGE} is the percentage you wanted to achieve.

     

    I hope this heps.

     

    YY

  • Options
    amotleyamotley Member Posts: 17 Contributor II

    YY,

     

    I tried this, but when I tried to run the process it came up with a "Undefined macro: TOT_FOOTAGE" error message. 

    Did I do something wrong?

  • Options
    yyhuangyyhuang Administrator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 364 RM Data Scientist
    Could you check the execution order of operators? If the macro is setup before it is used, it should be fine. Let me share a sample process later today.
  • Options
    yyhuangyyhuang Administrator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 364 RM Data Scientist
  • Options
    yyhuangyyhuang Administrator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 364 RM Data Scientist

    Sample process 

     

    Extract Macro.rmp

     

    https://dl.dropboxusercontent.com/u/12092138/Extract%20MACRO.rmp

     

    For some reason I dont know, I can not upload the rmp file here (it keep complain "The contents of the attachment doesn't match its file type")

Sign In or Register to comment.