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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Param from one formula to another

Status
Not open for further replies.

TanyaHarp

Programmer
Sep 21, 2011
19
CA
I am thinking no but its worth
Can you send parameters from one formula to another? So that i can have a couple different formulas call one other formula and depending on the parameter they send over it will set the condition.

ie.

@form1, @form2, @form3 all call @forma

For the conditional statement in forma to make a decision it needs to know if its form # 1, 2, or 3 that is calling it.

 
Tanya,

You can generally use formula's and parameters in other formulas... but you will need to be more specific as to your intent to provide you more information than this.

The choice as to what formula does what can likely be achieved with formula logic, either IF, CASE, etc.

Hope this helps, cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
The first three formulas are used in a cross tab. The forma sets a number which is dependant on which formula is calling it.

so
//@forma
numbervar form = 1; \\ or 2, 3 depending on which called this formula
if form = 1 then
dothis else
if form = 2 then
dothis else
if form = 3 then
dothis
 
Tanya,

The value of [blue]NumberVar[/blue] Form should be set in the other formula's.

The the first line of your formula shown would just be:
{@forma}
Code:
[blue]NumberVar[/blue] form;
[blue]IF[/blue] form = 1 [blue]THEN[/blue] dothis [blue]ELSE[/blue]
[blue]IF[/blue] form = 2 [blue]THEN[/blue] dothis [blue]ELSE[/blue]
[blue]IF[/blue] form = 3 [blue]THEN[/blue] dothis
If you set the value of "form" at the top of {@forma} (as in your post), it will always use the IF associated with the value you have set.

If you would like further assistance, can you please post the contents of {@Form1}, {@Form2}, and {@Form3} as well.

Hope this helps, cheers!


Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Sorry was out yesterday with a sick little one.

Here is what I got.

One of the following for each Quarter which is used as a column in a cross tab
//{@Qtr1}:
if {@qtrst} = 1 then
{@dayscurrqtr} else
if {@qtrend} = 1 then
{@daysnextqtr}

One of these for quarter 2, 3, and 4
//{@qtr2total}
numbervar qtr2total:= {@Qtr2} + {@Qtr2mid}


//@{Qtr2mid}
if {@qtrmid1} = 1 then
{@daysoutofqtr} else
if {@qtrmid2} = true then
{@daysoutofqtr};

This checks to see if the length of stay was 3 quarters another will check for 4.
//{@qtrmid1}:
datevar start := {VIEW.STARTN_DATE};
numbervar days := {VIEW.LENGTH_OF_STAY};
datevar end := start + days-1;
numbervar midqtr1 := 0;
numbervar quarter := 0;
if datepart("q", end) - datepart("q",start) = 2 then
midqtr1 := 1;


This one sends back the number of days in a quarter. Problem is depending on what quarter is calling this formula I want to do some different logic with it. Ie. If the middle quarter is 2, then it will still add 92 days to the third quarter even though its the last quarter of the formula and won't have someone staying the full duration of the quarter, may only have 10 days used but will send back 102 days.
//{@daysoutofqtr}
datevar start := {VIEW.START_DATE};
numbervar days := {VIEW.LENGTH_OF_STAY};
datevar end := start + days-1;
numbervar dysoutofqtr := 0;

if datepart("q", end) - datepart("q",start) = 2 then
dysoutofqtr := {@daysonemidqtr}
else if datepart("q", end) - datepart("q",start) = 3 then
dysoutofqtr := {@daysonemidqtr}
else if datepart("q", end) - datepart("q",start) = -1 then
dysoutofqtr := 0
 
Ok, to simplify I've decided on a better placement for what I'm trying to achieve. My question now is how do you do a between?

//{@Qtr2mid}
datevar start := {VIEW.START_DATE};
numbervar days := {VIEW.LENGTH_OF_STAY};
datevar end := start + days-1;

numbervar firstquarter := datepart("q",start);
numbervar lastquarter := datepart("q",end);
numbervar currentquarter := 2;


if currentquarter between firstquarter lastquarter than
(
if {@qtrmid1} = 1 then
{@daysoutofqtr} else
if {@qtrmid2} = true then
{@daysoutofqtr};
)
else
0;

or do I just do

if currentquarter > firstquarter then
if currentquarter < lastquarter then
(
if {@qtrmid1} = 1 then
{@daysoutofqtr} else
if {@qtrmid2} = true then
{@daysoutofqtr};
)
else
0;
 
Tanya,

I assume you are referring to this line of code?
TanyaHarp 30 Sep 11 8:56 said:
if currentquarter between firstquarter lastquarter than

For "Between" I personally use the "in" function. You can also use a combination of <= and >= formulas. Please see the following:

{@Between_UsingIN}
Code:
...[Blue]IF[/blue] currentquarter [Blue]in[/Blue] [firstquarter [Blue]to[/Blue] lastquarter] [Blue]THEN[/Blue]...

{@Between_UsingGrtrThnLessThn}
Code:
...[Blue]IF[/blue] currentquarter >= firstquarter [blue]AND[/blue]currentquarter <= lastquarter] [Blue]THEN[/Blue]...

Hope this helps!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Tanya,

Quick point of clarity: "in" is StartDate to EndDate inclusive. If you wish to see only those ones between and not including the starting and ending values, change the second example above to ">" and "<" instead of ">=" and "<=".

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
*sigh* My apologies, it is clearly too early still...

there is also no "]" in the second formula and a space beteeen "AND" and "currentquarter".

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Thanks Mcuthill, the first example is exactly what i am looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top