• Hi.

    I am using a procedure or just a SQL-Statement like this:

    select

    -- dynamic row-grouplevel 1

    case

    when @paramRowGroupLevel1 = 1 then t1.Category

    when @paramRowGroupLevel1 = 2 then t1.ExecutiveName

    when @paramRowGroupLevel1 = 3 then t1.ClientName

    when @paramRowGroupLevel1 = 4 then ''

    else ''

    end AS GroupRow1,

    -- dynamic row-grouplevel 2

    case

    when @paramRowGroupLevel2 = 1 then t1.Category

    when @paramRowGroupLevel2 = 2 then t1.ExecutiveName

    when @paramRowGroupLevel2 = 3 then t1.ClientName

    when @paramRowGroupLevel2 = 4 then ''

    else ''

    end AS GroupRow2,

    -- dynamic col-grouplevel 1

    -- analog to the row-grouplevel

    sum( t1.sales ) sales

    from

    salestable t1

    where

    year = @paramYear

    -- (and ...)

    group by

    case

    when @paramRowGroupLevel1 = 1 then t1.Category

    when @paramRowGroupLevel1 = 2 then t1.ExecutiveName

    when @paramRowGroupLevel1 = 3 then t1.ClientName

    when @paramRowGroupLevel1 = 4 then ''

    else ''

    end,

    -- dynamic row-grouplevel 2

    case

    when @paramRowGroupLevel2 = 1 then t1.Category

    when @paramRowGroupLevel2 = 2 then t1.ExecutiveName

    when @paramRowGroupLevel2 = 3 then t1.ClientName

    when @paramRowGroupLevel2 = 4 then ''

    else ''

    end

    -- dynamic col-grouplevel 1

    -- analog to the row-grouplevel

    In the report the field GroupRow1 is the first grouped row. GroupRow2 is the second.

    If you wish to suppress the rows with empty values for GroupRow1 or GroupRow2 you could calculate the row-hidden-attribute.

    Hope this helps

    .akoeli