Numbering columns in matrix Tablix

  • 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!

  • 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 problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • 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).

  • 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 problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • 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!

  • 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 problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • 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 problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • Thank you so much! I'll give this a shot and let you know how it goes.

  • 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 SOPNUMBE

    Row 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!

  • 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 problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • mahler9 (6/18/2013)


    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 SOPNUMBE

    This shouldn't affect things, as long as you are not creating duplicates by stripping the prefix.

    Row 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!

    The reason you only get Insert Row ...Above or Below is because you already have another row inside the group above the cell you are right clicking on, so it can only insert inside the group from there.

    Can you post the expression you used for the column numbering?

    edit: I meant to say, I just tried this on BIDS 2008 and it worked just fine...

    MM



    select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);

  • Forum Etiquette: How to post Reporting Services problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • Thanks for your response!

    I pasted the following expression into the cell above expression for order number,

    =RunningValue(CountDistinct(Fields!SalesOrder.Value),SUM,"DataSet1")

    then edited, replacing "SalesOrder" with "SOPNUMBE".

    I am also using BIDS 2008.

  • Is your dataset called Dataset1? If not, you need to change that.

    Can you paste here the exact expression you are using?

    MM



    select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);

  • Forum Etiquette: How to post Reporting Services problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • Dataset1 is indeed the name of the dataset.

    Exact expression: =RunningValue(CountDistinct(Fields!SOPNUMBE.Value),SUM,"DataSet1")

  • Let's try something, attached is a working report with column numbering.

    It uses inline XML data, so no need to connect to SQL to run it, just open the project and preview the report.

    Once you confirm whether it is working, you can examine the report - it is simply a matrix with two row groups and one column group with two rows in the column group and our friendly expression on the top cell.

    MM



    select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);

  • Forum Etiquette: How to post Reporting Services problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

    Viewing 15 posts - 1 through 14 (of 14 total)

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