Print Page | Close Window

Multiplying Array by formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22740
Printed Date: 27 Apr 2024 at 8:48am


Topic: Multiplying Array by formula
Posted By: CR_Steve
Subject: Multiplying Array by formula
Date Posted: 08 Mar 2019 at 6:49am
I have the following formula
if {@1st_sort} = "LABOR" then
      [{CfgCalc.AICCost1}, {CfgCalc.AICCost2}, {CfgCalc.AICCost3}, {CfgCalc.AICCost4}, {CfgCalc.AICCost5}] [{@QtyIndex}]*{@LaborMU})

this formula is is in Group Header #3 and is summarized in GF#3. But as you can imagine it is coming in blank. Is there a way to display the @LaborMU as a number so that the CfgCalc.AICcost will multiply.

Thanks for any help



Replies:
Posted By: hilfy
Date Posted: 11 Mar 2019 at 7:17am
What does the @LaborMU formula look like? If it returns an array, what type of data is in the array? If the array contains numbers, how would you want to handle it in this situation - concatenate the numbers, sum the numbers, multiply the numbers?

-Dell

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: CR_Steve
Date Posted: 14 Mar 2019 at 5:24am
This is Th @LaborMU formula
1+({@PrtLaborOAMkup}/100)

And this is the @PrtLaborOAMkup formula
formula = {@LaborOAMarkup}*100

And this is the @LaborOAMarkup formula
[ {OverallMarkups.LaborQ1}, {OverallMarkups.LaborQ2}, {OverallMarkups.LaborQ3}, {OverallMarkups.LaborQ4}, {OverallMarkups.LaborQ5} ] [{@QtyIndex}]




Posted By: hilfy
Date Posted: 20 Mar 2019 at 9:37am
I think I know what the problem is. You can't display something in a group header that doesn't have data until after all of the group data is processed. However, there is a way around this if there will only be one value for the result at the end of the group.

Try this:

WhilePrintingRecords;
if {@1st_sort} = "LABOR" then
MAXIMUM(
    [{CfgCalc.AICCost1}, {CfgCalc.AICCost2},
     {CfgCalc.AICCost3}, {CfgCalc.AICCost4},
     {CfgCalc.AICCost5}] [{@QtyIndex}]*{@LaborMU})


-Dell

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: CR_Steve
Date Posted: 22 Mar 2019 at 7:37am
This is the entire formula

if {@1st_sort} = "OUTSD" or {@1st_sort} = "DELVRY" then [{CfgCalc.Cost1}, {CfgCalc.Cost2}, {CfgCalc.Cost3}, {CfgCalc.Cost4}, {CfgCalc.Cost5}] [{@QtyIndex}] * 1.15
 else if {@1st_sort} = "LABOR" then

      [{CfgCalc.AICCost1}, {CfgCalc.AICCost2}, {CfgCalc.AICCost3}, {CfgCalc.AICCost4}, {CfgCalc.AICCost5}] [{@QtyIndex}]*{@LaborMU}

 else if {@1st_sort} = "MATRL"   then
    (  if {@2nd_sort} = "001" then
        [{CfgInkCalc.Cost1}, {CfgInkCalc.Cost2}, {CfgInkCalc.Cost3}, {CfgInkCalc.Cost4}, {CfgInkCalc.Cost5}] [{@QtyIndex}] * 1.1
       else if {@2nd_sort} = "000" then
        [{CfgStockCalc.Cost1}, {CfgStockCalc.Cost2}, {CfgStockCalc.Cost3}, {CfgStockCalc.Cost4}, {CfgStockCalc.Cost5}] [{@QtyIndex}] * 1.12
       else
         [{CfgCalc.Cost1}, {CfgCalc.Cost2}, {CfgCalc.Cost3}, {CfgCalc.Cost4}, {CfgCalc.Cost5}] [{@QtyIndex}] * 1.1
       )
else 0

This is in Group header #3 and it is suppressed. This is then summed in Group Footer# 3
But the red text is coming in blank.
2nd sort calculates fine. You can see that it is multiplied by a number. Whereas 1st sort need to be multiplied by a formula because the value will change. @LaborMU is a user input number



Print Page | Close Window