Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making a single number by typecode a variable to be used anywhere 2

Status
Not open for further replies.

DJWheezyWeez

Technical User
Jun 5, 2008
265
US
I'm using CR XI.

I'm trying to get a number to use as constant variable... Let me try to explain in code.
Code:
IRN       Qty    Value  UnitPrice  Type
53004    0.00   494.40    1.03     Price Change
53004  -36.00   -37.08    1.03     Issue
53004 -210.00  -216.30    1.03     Issue
53004 -234.00  -241.02    1.03     Issue
53004  480.00     0.00    0.00     Receipt
53005    0.00   494.40    1.03     Price Change
53005 -168.00  -173.04    1.03     Issue
53005  480.00     0.00    0.00     Receipt
53006  480.00     0.00    0.00     Receipt
53007  480.00     0.00    0.00     Receipt
53008  480.00     0.00    0.00     Receipt
67663  480.00     0.00    0.00     Receipt
94035  480.00     0.00    0.00     Receipt
94036  480.00     0.00    0.00     Receipt
94037  480.00     0.00    0.00     Receipt
94038  480.00     0.00    0.00     Receipt

So for each IRN, not looking at the Issues, the Value is the Qty for the Receipt times the UnitPrice. On this report, I'm going to be restricting to only Receipts but I still want that 1.03 UnitPrice number. Is there a way to get that single number of 1.03 into a shared variable that I can use anywhere I want? In other words, I would like to get the number 1.03 on every line in the UnitPrice column so I can do a formula to multiply across with the Qty to get a Value for the Receipts. I've tried doing it in a subreport and it works until I restrict to only Receipts which makes sense. Any thoughts?

-DJWW

 
Hi,
Try just a simple formula and add it to the detail section bewteen any of the fields..It can be supressed so you do not see it but can use it in calculations:
@Constant_103
Code:
NumberVar myConst := 1.03;
myConst

Never tried it ( not at CR right now), but should work


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Well it's not always 1.03. It just is in this example. I found somewhat of a work around, not exactly what the person wanted but it'll do.
 
Hi,'
Sorry, I was confused by your statement:
DJWheezyWeez said:
Is there a way to get that single number of 1.03 into a shared variable that I can use anywhere I want? In other words, I would like to get the number 1.03 on every line in the UnitPrice column



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
This example is for one Vendor where the UnitPrice is 1.03. For other Vendors, the UnitPrice will be different. Instead of the code at the top, I'm looking for something like this:
Code:
IRN       Qty    Value  UnitPrice  Type
53004    0.00   494.40    1.03     Price Change
53004  -36.00   -37.08    1.03     Issue
53004 -210.00  -216.30    1.03     Issue
53004 -234.00  -241.02    1.03     Issue
53004  480.00     0.00    1.03     Receipt
53005    0.00   494.40    1.03     Price Change
53005 -168.00  -173.04    1.03     Issue
53005  480.00     0.00    1.03     Receipt
53006  480.00     0.00    1.03     Receipt
53007  480.00     0.00    1.03     Receipt
53008  480.00     0.00    1.03     Receipt
67663  480.00     0.00    1.03     Receipt
94035  480.00     0.00    1.03     Receipt
94036  480.00     0.00    1.03     Receipt
94037  480.00     0.00    1.03     Receipt
94038  480.00     0.00    1.03     Receipt

If I can get that then I'm hoping I can do a calculation and get 1.03*480.00 to equal the 494.40 for each Value with the Type of Receipt. I hope that makes more sense.

Currently I have a subreport restricted to Types Issue and Price Change showing the UnitPrice in a formula making it a shared variable. The only way it works in my main report is if I leave the Type unrestricted and have either an Issue or Price Change on the first line of my report. Otherwise every formula that I reference the shared variable in comes out to 0.
 
Instead of restricting the report (I think you are talking about record selection) could you suppress records of type issue and price change in the section expert? Your formulas will remain in tact but you wont see the suppressed records.

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
I hadn't thought of that CoSpringsGuy, thanks. I'll try that.
 
Did not seem to work CoSpringGuy. I think it was working the same way as restricting the subreport to Issues and Price Change.
 
I completely missed the comment about a subreport. Do you need it to be a subreport? My suggestion was based on the data you supplied not considering a subreport. I dont have a lot of experience with them to be honest. I would think it would matter as far as supressing data is concerned. From your description though I think you could accomplish what you are trying to do without one. I assume your need for one extends beyond the issue your having though.

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Please explain where the unitprice is coming from. Is this really hard coded per vendor or do you have it as a {table.field}. Wherever it is coming from, if there is always only one value per vendor, then you could just use:

maximum({table.unitprice},{table.vendor})

...in all your calculations.

-LB
 
Thank you CoSpringsGuy for questioning the need for a subreport. In trying a bunch of different work arounds, I had so many random formulas and shared variables that I just needed to start with a new subreport. Turns out the original subreport I was working with was simple enough that I didn't need it. I used your previous suggestion of suppressing on a types I don't want then I used lbass's maximum formula to get what I needed.

Thank you both for the help. Still need some fine tuning with totals and making it work for more vendors but now that I'm over this hump, I should be fine.

-DJWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top