How do I get the number of rows that Duplicates merges?

Hi, All

After merging rows with Duplicates=Merge, how do you show how many rows are merged in another column?

Comments

  • edited August 2018
    just send filtered data to fastreport >
    // original data
    List<Tuple<int, string, int>> list = new List<Tuple<int, string, int>>()
    {
        new Tuple<int, string, int>(1, "AAA", 1),
        new Tuple<int, string, int>(2, "AAA", 1),
        new Tuple<int, string, int>(3, "AAA", 1),
        new Tuple<int, string, int>(4, "BBB", 1),
        new Tuple<int, string, int>(5, "BBB", 1),
        new Tuple<int, string, int>(6, "AAA", 1),
        new Tuple<int, string, int>(7, "CCC", 1),
        new Tuple<int, string, int>(8, "DDD", 1),
        new Tuple<int, string, int>(9, "DDD", 1),
        new Tuple<int, string, int>(10, "DDD", 1)
    };
    
    // filtered data
    List<Tuple<int, string, int>> result = new List<Tuple<int, string, int>>();
    
    int counter = 0;                        // counter for output
    int sequence = 0;                       // first record or not            
    int bufferInt = 0;                      // previous value                  
    string bufferString = list[0].Item2;    // previous value
    
    // running test
    foreach (var item in list)
    {
        // (current record is not equal to previous record) AND (current record is not first record)
        if (sequence > 0 && !item.Item2.Equals(bufferString))
        {
            result.Add(new Tuple<int, string, int>(++counter, bufferString, bufferInt));
            bufferInt = item.Item3;
            bufferString = item.Item2;
        }
        // (current record equals to previous record)
        else
        {
            bufferInt += item.Item3;
        }
        sequence++;
    }
    
    // adding the result from last test
    result.Add(new Tuple<int, string, int>(counter++, bufferString, bufferInt));
    
    // display the result
    foreach (var item in result)
    {
        MessageBox.Show(string.Format("{0} {1} {2}", item.Item1, item.Item2, item.Item3));
    }
    
  • edited January 2019
    Thank you ipong, if it can not be implemented in FR, it seems that we have to build the data source according to the expected format to FR! Thanks!

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.