## Numbering columns in matrix Tablix

 Author Message mahler9 SSC-Enthusiastic Group: General Forum Members Points: 181 Visits: 90 Update: Added attachment (PDF)Disclaimer: Noob in the house. I'll try to phrase the question correctly.SSRS Picking Report uses dataset in matrix. Data Set is a Pick List with varying numnber of Sales Orders having multiple lines per order. Lines contain Bin location and Item Quantity. Item Quantity is aligned with each corresponding column header(order). The Orders are grouped in columns which expand dynamically to the right. The Line Items comprise the rows. The Tablix is sorted by the rows (Bin location).I would like to autonumber, dynamically, the columns (distinct orders). "1" for the first column (order), "2" for the second column, "3" and so on.I've tried several suggestions online, generally involving getCount in Code, and expression referencing the code. None work. If I have 10 columns, columns are ordered non-sequentially based on logic I'd spin my wheels trying to figure out.I also tried CountDistinct(OrderNumber).I'm throwing darts, blindfolded, at this point. One will surely hit me on the head without your help.Thanks! Attachments AutoNumberingColumnsInMatrixWithSortingByRows.pdf (15 views, 36.00 KB) mister.magoo One Orange Chip Group: General Forum Members Points: 26756 Visits: 7939 Are you trying to number the columns in order to just put a number in the column title? or some other purpose?Generally, I would say just add a row_number over(partition by product order by whatever) column to your dataset.Then you can display the row_number value in the column title - you will need to sort the matrix column group by the row_number to make sure the numbers come out in order. MM`select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);`Forum Etiquette: How to post Reporting Services problemsForum Etiquette: How to post data/code on a forum to get the best help - by Jeff ModenHow to Post Performance Problems - by Gail Shaw mahler9 SSC-Enthusiastic Group: General Forum Members Points: 181 Visits: 90 Thanks for your reply, appreciate it.Yes, I'm trying to "auto-number" number, left to right, the columns in the order in which they appear. The columns (Sales Orders) are ordered by the Row sort (Bin Location). I'm not sure this can have anything to do with changing the matrix sort must follow the rows.Does this explain more? Will row_number over still work to dynamically number however many columns appear (generally 1 to 8 columns). mister.magoo One Orange Chip Group: General Forum Members Points: 26756 Visits: 7939 Yes, it sounds like adding something like `ROW_NUMBER() OVER(PARTITION BY ZN,Bin,Item ORDER BY [Order Number]) as [Column Number]`...but you still haven't said what order the columns (order numbers) are in, so I had to guess at order number order...remember there is no such thing as "Row order" unless you specify one.EDIT: just saw the PDF so edited... MM`select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);`Forum Etiquette: How to post Reporting Services problemsForum Etiquette: How to post data/code on a forum to get the best help - by Jeff ModenHow to Post Performance Problems - by Gail Shaw mahler9 SSC-Enthusiastic Group: General Forum Members Points: 181 Visits: 90 Thanks again.I will give that a look, though admittedly I'm not exactly sure how\where this goes in the report.I am also attaching a second PDF with Tablix and Group Properties which may explain what I was trying to! Attachments AutoNumberingColumnsInMatrixWithSortingByRows_page2.pdf (10 views, 27.00 KB) mister.magoo One Orange Chip Group: General Forum Members Points: 26756 Visits: 7939 Sorry, I see now - you will have orders that span multiple rows and rows that span multiple orders...so the row_number won't help...but I have an idea...I will let you know if I come up with something... MM`select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);`Forum Etiquette: How to post Reporting Services problemsForum Etiquette: How to post data/code on a forum to get the best help - by Jeff ModenHow to Post Performance Problems - by Gail Shaw mister.magoo One Orange Chip Group: General Forum Members Points: 26756 Visits: 7939 I got something to work - try this:Select your "SalesOrder" column/field in the matrix and insert a row "inside group - above" and add this expression (edited to suit your dataset)`=RunningValue(CountDistinct(Fields!SalesOrder.Value),SUM,"DataSet1")`My dataset was called DataSet1 and my Sales Order column was called SalesOrder - just change to suit.This will (it does on mine) add a running count to that new field: MM`select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);`Forum Etiquette: How to post Reporting Services problemsForum Etiquette: How to post data/code on a forum to get the best help - by Jeff ModenHow to Post Performance Problems - by Gail Shaw Attachments Column Numbers.PNG (55 views, 7.00 KB) mahler9 SSC-Enthusiastic Group: General Forum Members Points: 181 Visits: 90 Thank you so much! I'll give this a shot and let you know how it goes. mahler9 SSC-Enthusiastic Group: General Forum Members Points: 181 Visits: 90 I received an error when building the report. However, I am not certain whether or not I executed your suggestion the way you intended. Please see the attached PDF.Also, I'm wondering if\how the following report components factor into things.Order number expression: =replace(Fields!SOPNUMBE.Value,"DTCI","") --strips "DTCI" from SOPNUMBERow groups: matrix1_BinNumber (group/sort on BinNumber), matrix1_ItemNumber (group/sort on ItemNumber), matrix1_ItemDescription (group/sort on ItemDescription)Column groups: matrix1_SITE (groups on SOPNUMBE, sorts by Location)Thanks again! Attachments RunningTotalExpression_Error.pdf (21 views, 67.00 KB) mister.magoo One Orange Chip Group: General Forum Members Points: 26756 Visits: 7939 Ah, it may be a new feature of 2012 then...sorry hadn't noticed that.Maybe there will be another way... MM`select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);`Forum Etiquette: How to post Reporting Services problemsForum Etiquette: How to post data/code on a forum to get the best help - by Jeff ModenHow to Post Performance Problems - by Gail Shaw