"Macro to calulate % of a value"

AnkiAnki MemberPosts:39Maven
edited May 2019 inHelp
Hi Matthias and all,

I want to write a macro to calulate 20% ( percent ) of a value. My problem is like this

CUST_ID TRAN_COUNT
--------------------------------------
23145 23
34562 87

I want to Iterate the process for each CUST_ID and In the inner loop I am reading data belongs to CUST_ID and I am passing it to "Outlier Analysis".
In Outlier Analysis I need to give input 'count_of_outlier' as 20% of TRAN_COUNT.
I am taking macro "extract macro" .....But How can I calulate % of that value?

Thank you

Yours
Anki
Tagged:

Answers

  • colocolo MemberPosts:236Maven
    Hi Anki,

    if you already have the value extracted as a macro, you can generate a new one using expressions via "Generate Macro". Here a small example illustrating this.





    <宏/ >

    <运营商激活类= = " true ""process" compatibility="5.1.008" expanded="true" name="Process">

    <运营商激活类= = " true ""generate_data" compatibility="5.1.008" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">



    <运营商激活类= = " true ""select_attributes" compatibility="5.1.008" expanded="true" height="76" name="Select Attributes" width="90" x="179" y="30">





    <运营商激活类= = " true ""extract_macro" compatibility="5.1.008" expanded="true" height="60" name="Extract Macro" width="90" x="313" y="30">





    <运营商激活类= = " true ""generate_macro" compatibility="5.1.008" expanded="true" height="76" name="Generate Macro" width="90" x="447" y="30">




    <运营商激活类= = " true ""generate_attributes" compatibility="5.1.008" expanded="true" height="76" name="Generate Attributes" width="90" x="581" y="30">















    "Generate Attributes" is just used to show the computed macro value. Instead of generating output this way, you will have to use the new macro as input parameter for "Outlier Analysis". You will certainly need integer values, so you can wrap the "Generate Macro" expression included above inside the ceil() or floor() function, e.g. ceil(%{tran_count} * 0.2)

    Best regards
    Matthias
  • AnkiAnki MemberPosts:39Maven
    Hi Matthias

    Thanks a lot.

    Yours
    Anki
Sign InorRegisterto comment.