Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

percentage calculation in form

(0) ShareShare
ReportReport
Posted on by 325

Hi all i have a three fields in my form

1.current salary

2.expected salary

3.hike percentage

i will create create and ill enter current and expected salary once i enter a expected salary hike percentage should calculate automatically  how can i achieve it ,which method i need to write.

Thanks in advance.............. 

*This post is locked for comments

  • Shonist Profile Picture
    Shonist 5 on at
    RE: percentage calculation in form

    Hi, kartheek MV. Try to connect any percentage calculator via API and adjust the increase and calculation of interest for a specific period of time. Good luck!

  • Tillhasky Profile Picture
    Tillhasky 5 on at
    RE: percentage calculation in form

    I think yes, but I wonder how it works? Because I think that you need to use a calculator that can calculate with different options that simple calculator can work. Since usually I have a situation, when I tried to calculate my salary with my family and simple calculator is taking too much time to do that and that's why I started to find different calculators on different topics, where I found an article about "percentage calculator" that was pretty useful for me (since it has a simple interface) which I am very happy about.

  • TacticalKarma Profile Picture
    TacticalKarma 15 on at
    RE: percentage calculation in form

    so can this calculator calculate for exemple loans?

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: percentage calculation in form

    One question, why do you make a select on PackageTbl, if you are not using the buffer afterwards? You can remove the variable and the select statement from your code. this keyword refers to the current buffer, based on which you are doing your calculation.

  • karthik143 Profile Picture
    karthik143 325 on at
    RE: percentage calculation in form

    Display Percent hike()

    {

       PackageTbl pkg;

       real   c;

       select * from pkg where pkg.Name == this.Name;

       if(this.CurrentCTC != 0)

       {

          c=(((this.ExpectedCTC-this.CurrentCTC)/this.CurrentCTC)*100);

       }

       return c;

    }

    final code thanks for suggetion mr.Vilmos Kintera

  • Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: percentage calculation in form

    Please make helpful answers as Verified instead of pressing Like, to resolve the topic. It is on the right of each post. Thank you

  • Verified answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: percentage calculation in form

    Division by zero means your dividend is zero, meaning you would get a result of infinite in your equation.

    Make sure you handle that if this.currentCTC = 0, then return c as 0 too.

    Something like:

    c = this.CurrentCTC != 0 ? ((this.ExpectedCTC-this.CurrentCTC)/this.CurrentCTC)*100 : 0;


  • Suggested answer
    Rohin Profile Picture
    Rohin 4,624 on at
    RE: percentage calculation in form

    try to write code in formDataSource modifed() method of expected CTC field :

    public void modified()

    {

       Amount    increase;

       if(table.ExpectedSalary != 0)

       {

           increase = table.ExpectedSalary - table.CurrentSalary;

           table.HikePercentage = (increase/table.CurrentSalary)*100;

       }

       super();

    }

  • karthik143 Profile Picture
    karthik143 325 on at
    RE: percentage calculation in form

    pkg.png

    hanks for reply mr.Vilmos Kintera

    i have tried already display method

    just look in to my code

    Display Percent hike()

    {

       PackageTbl pkg;

       real   c,;

       select * from pkg where pkg.Name == this.Name;

       c=((this.ExpectedCTC-this.CurrentCTC)/this.CurrentCTC)*100;

       return c;

    }

    if compile that code i am not getting any errors if open my form i am getting error please find the above image.

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: percentage calculation in form

    First of all, are your fields bound to a datasource? If yes, is it the same table/datasource? In that case you could write a display method on the Table with the calculation, add a new field to your form where you set the Datasource property on the form control to your datasource, and the Data method property to the display method. That will automatically take care of showing your calculation. Also consider caching the display method. You can find all the details for this on MSDN in the AX documentation.

    If your fields are not bound controls, in that case you could have your calculation on the Form's methods directly. Override the modified() method on each of your form controls, and call your new method from the modified(), which does the calculation and assigns the value to your summary field.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,820 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans