How to split cells in table format?

  • You can do this but you'll have to resort to using a cursor in your stored proc that feeds the report.

    I had to do something similar in a statement where I needed to list all the names associated with a row item and put the list of names in the one cell.

  • I'm not sure I entirely understand your question, but it sounds like you want to convert rows to columns. You might looks into using PIVOT in your query.

    Check in BOL for syntax and explanation on PIVOT.

    This should get you to the following format in your report

    Item A

    1 2 3

    Then you could set your report to be a multi-column report. You do this by going into Report Properties and on the layout tab set Columns to 2 and in Spacing set the width of space you want between the columns. This should give you this format in your report.

    Item A Item B

    1 2 3 1 2 3

    Check in BOL under SQL Server Reporting Services for multiple columns.

    Hope this helps.

    KDW

  • Change your table properties in you report. Make your rows your columns and your columns your rows!in sql, this logic will help in creating a dynamic sql, depending on whether u need to create a table or not, will help in fulfiling your wish:

    declare @SQL1 VARCHAR(50)

    declare @SQL2 VARCHAR(50)

    select @SQL1 = ''

    select @SQL2 = ''

    select @sql1 = @SQL1 + Val + ',' from #Sello

    select @sql2 = @SQL2 + CAST(Row as char(2))+ ',' from #Sello

    SELECT LEFT(@SQL1, LEN(@Sql1)-1)

    UNION

    select LEFT(@SQL2, LEN(@Sql2)-1)

    U can omit the ',' and use ' ' to separate the fields!

  • Have you tried a cross tab report, then just turned off the detail rows?

  • meghna.bhargav (4/5/2008)


    Hi Guys,

    I have this table formatting problem; In this report each item has 2 rows. I want to split the send row as shown below. So the results of the report should have the format below.

    rownumber ITEMNUNBER

    1 A

    2 A

    3 B

    4 B

    5 C

    6 C

    i wna display in this way mentioned below:

    A B

    1 2 3 4

    Any help appreciated!

    thanks

    Meghna

    A matrix report will do the pivoting you describe.

    col1 col2 col3 col4

    --------------------

    north 1 A 15

    north 2 A 20

    north 3 B 30

    south 3 B 12

    south 4 B 14

    south 5 C 16

    west 6 C 18

    matrix report:

    | A | B | C |

    | 1 | 2 | 3 | 4 | 5 | 6 |

    |col4|col4|col4|col4|col4|col4|

    north | 15 | 20 | 30 | | | |

    south | | | 12 | 14 | 16 | |

    west | | | | | | 8 |

    In the above report, col1 is a "row" field, col2 and col3 are "column" fields, and col4 is a "detail" field.

    Working with Matrices (Report Builder): http://technet.microsoft.com/en-us/library/aa337159.aspx

  • Thanks , i used matrix and it worked.

    Meghna

  • Thanks to all of you for all splendid solutions and for spending your valuable time on this issue.

    i got it and now its working !

    Thanks

    Meghna

  • antonio.collins (4/9/2008)


    A matrix report will do the pivoting you describe.

    Nicely done...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Yes , i did, its done beautifully.

Viewing 9 posts - 16 through 23 (of 23 total)

You must be logged in to reply to this topic. Login to reply