Calculate percentage in reports designer
rbnsncrusoe
Member Posts: 2
Hello!
I’m working with a report which shows total sales amount per country. It also includes a grand total of all sales at the bottom of the report.
The end user has requested that I include the percentage of total sales for each country. I am at a loss how to do this in Nav.
Obviously, I have to divide each country’s sales by the total sales, but the total sales are not calculated until the end of the report (in the footer). Is there something I can do to make it loop in the header, grab the total and then use that variable in the body? Have any other ideas, cause I'm at my wits end.
Thank you very much!
I’m working with a report which shows total sales amount per country. It also includes a grand total of all sales at the bottom of the report.
The end user has requested that I include the percentage of total sales for each country. I am at a loss how to do this in Nav.
Obviously, I have to divide each country’s sales by the total sales, but the total sales are not calculated until the end of the report (in the footer). Is there something I can do to make it loop in the header, grab the total and then use that variable in the body? Have any other ideas, cause I'm at my wits end.
Thank you very much!
0
Comments
-
As you know, you need to calculate the value for total before you will start the iteration. it means some new record variable which you will use to calculate the sum. And how it depends on the structure, if you are going in one level or you have some other nested levels, fitlers (for example if some records are skipped through code etc.). If there are just filters from user, you can copy the filters and use CALCSUMS to sum the fields but it can be more complicated in other cases.0
-
The Aged Accounts Receivable does this - You can see how it's done there to get an idea
CalcPercents(Total : Decimal;Amounts : ARRAY [4] OF Decimal) CLEAR(PercentString); IF Total <> 0 THEN FOR i := 1 TO 4 DO BEGIN Percent := Amounts[i] / Total * 100.0; IF STRLEN(FORMAT(ROUND(Percent))) + 4 > MAXSTRLEN(PercentString[1]) THEN PercentString[i] := PADSTR(PercentString[i],MAXSTRLEN(PercentString[i]),'*') ELSE BEGIN PercentString[i] := FORMAT(ROUND(Percent)); j := STRPOS(PercentString[i],'.'); IF j = 0 THEN PercentString[i] := PercentString[i] + '.00' ELSE IF j = STRLEN(PercentString[i]) - 1 THEN PercentString[i] := PercentString[i] + '0'; PercentString[i] := PercentString[i] + '%'; END; END;
4 is for the current-30-60-90 - so I would assume you change that number to the number of countries you deal with.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 327 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
