Joris Aarts Posted September 29, 2005 Posted September 29, 2005 Laat toe om sum, count, max, ... te berekenen voor een variabele met meerdere repetitions. Je kan elke built-in FileMaker aggregate function gebruiken. Syntax: ArrayStats(Sum|Count|Average|... , $variabele, aantalRepetitions, temp) Voorbeeld: Variabele $Array met 3 repetitions: $Array[1] = 7 $Array[2] = 6 $Array[3] = 10 ArrayStats("Sum"; "$Array"; 3; "") = 23 ArrayStats("Average"; "$Array"; 3; "") = 7,66666666667 ArrayStats("Sum"; "$Array"; 2; "") = 13 Voorbeeldbestand in bijlage ArrayStats.zip Quote
0 Joris Aarts Posted September 29, 2005 Author Posted September 29, 2005 Volledige functie als tekst (argumenten in eerste lijn): //Arguments: statFunction; varName; numRepetitions; temp //Calculates chosen stat for specified variable varName with number of repetitions in numRepetitions //Example: ArrayStats("Sum" ; "$TestVar";3) where $TestVar contains values 1,2,3 in three repetitions, returns 6 //statFunction can contain one of FileMakers Aggregate functions: Sum, Count, Min, Max, Average, ... Let([ nextRepetition = numRepetitions - 1; varWithRepetition = varName & "[" & numRepetitions & "]"; //expand variable to specific repetition newTemp = temp & ";" & varWithRepetition; //add result to chain of repetitions stripTemp = Middle(temp;Position(temp;";";1;1)+1;Length(temp)); //Remove everything before first ";" from chain for result resultString = statFunction & "(" & stripTemp & ")"; //set up final calculation string with all repetitions result = Evaluate(resultString) //Now calculate it ! ]; If( numRepetitions > 0; ArrayStats(statFunction; varName ; nextRepetition ; newTemp); result ) ) Veel groeten, Joris Aarts www.selene.be Quote
Question
Joris Aarts
Laat toe om sum, count, max, ... te berekenen voor een variabele met meerdere repetitions. Je kan elke built-in FileMaker aggregate function gebruiken.
Syntax:
ArrayStats(Sum|Count|Average|... , $variabele, aantalRepetitions, temp)
Voorbeeld:
Variabele $Array met 3 repetitions:
$Array[1] = 7
$Array[2] = 6
$Array[3] = 10
ArrayStats("Sum"; "$Array"; 3; "") = 23
ArrayStats("Average"; "$Array"; 3; "") = 7,66666666667
ArrayStats("Sum"; "$Array"; 2; "") = 13
Voorbeeldbestand in bijlage
ArrayStats.zip
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.