/// <summary>
        /// Generate new Intermediate with baselining values
        /// ${Appbeheer_01_Inloggen_br // reference (baseline value)
        /// ${Appbeheer_01_Inloggen_be // evaluated value (difference from baseline in %)
        /// ${Appbeheer_01_Inloggen_be_c // colorcode, mark when current value exceeds threshold th1, green when diff > -15%, red when diff > +15%
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="baselineIntermediate"></param>
        /// <param name="baselineReferenceIntermediate"></param>
        /// <param name="colorcodeBetter"></param>
        /// <param name="colorcodeWorse"></param>
        /// <returns></returns>
        public Intermediate GenerateBaselineEvaluationValues(Intermediate intermediate, Intermediate baselineIntermediate, Intermediate baselineReferenceIntermediate, string colorcodeBetter, string colorcodeWorse)
        {
            Intermediate result = new Intermediate();

            // voor alle items in de baseline reference: doe evaluatie
            foreach (KeyValuePair <string, string> baselinePair in baselineReferenceIntermediate)
            {
                // add _br value from baseline reference
                result.AddValue(GetBaselineReferenceKey(baselinePair.Key), baselinePair.Value);

                // evaluate and generate _be and _be_c values
                if (intermediate.ContainsKey(baselinePair.Key))
                {
                    string baselineValueSeries          = baselineIntermediate.GetValue(baselinePair.Key);
                    string baselineThresholdValueSeries = baselineIntermediate.GetValue(Thresholds.GetThresholdColorKey(baselinePair.Key));

                    string currentValueSeries          = intermediate.GetValue(baselinePair.Key);
                    string currentThresholdValueSeries = intermediate.GetValue(Thresholds.GetThresholdColorKey(baselinePair.Key));

                    // generate _be and _be_c values
                    Intermediate evalResult = GenerateEvaluation(baselinePair.Key, baselineValueSeries, currentValueSeries, baselineThresholdValueSeries, currentThresholdValueSeries, colorcodeBetter, colorcodeWorse);
                    result.Add(evalResult);
                }
            }

            return(result);
        }
        /// <summary>
        /// Return intermediate where key=value are replaced with -prefix-key=value
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="prefix"></param>
        /// <returns></returns>
        public static Intermediate ApplyKeyPrefix(Intermediate intermediate, string prefix)
        {
            Intermediate newIntermediate = new Intermediate();

            foreach (string key in intermediate.Keys)
            {
                newIntermediate.AddValue(prefix + key, intermediate[key]);
            }
            return(newIntermediate);
        }
        /// <summary>
        /// Generate new intermedate with new counters holding aggregated values (per column)
        /// </summary>
        /// <param name="aggregateKey"></param>
        /// <param name="keyPattern"></param>
        /// <param name="valuePattern"></param>
        /// <returns></returns>
        public Intermediate AggregateCount(string aggregateKey, string keyPattern, string valuePattern)
        {
            Log.WriteLine(string.Format("calculate aggregate {0} on {1}={2} ...", aggregateKey, keyPattern, valuePattern));

            Regex regKey = new Regex(keyPattern);
            Regex regVal = new Regex(valuePattern);

            Intermediate result = new Intermediate();

            // add aggregate values
            for (int i = 0; i < this.GetMaxNumOfValues(); i++)
            {
                //Log.WriteLine("aggregate value position: " + i);
                int aggr = 0;
                foreach (string key in this.Keys)
                {
                    if (regKey.IsMatch(key))
                    {
                        try
                        {
                            // beveiligd try/catch ivm onzekerheid aantal entry's in de value reeks
                            if (regVal.IsMatch(GetValue(key, i)))
                            {
                                //Log.WriteLine(string.Format("key={0} value={1}", key, GetValue(key, i)));
                                aggr = aggr + 1;
                            }
                        }
                        catch {}
                    }
                }
                //Log.WriteLine(string.Format("violations for position {0} = {1}", i, aggr.ToString()));
                result.AddValue(aggregateKey, aggr.ToString());
            }

            return(result);
        }