Solved

SSRS - Row Number excluding hidden rows

Posted on 2014-11-07
3
613 Views
Last Modified: 2014-11-26
I have a report that has some rows hidden from my table.  It is also grouped.  I would like to count each grouped rows, but it is also counting the hidden rows as well.  

I'm hoping for it to skip if the textbox23 is 0, since that's what I'm hiding.  Anything with a value zero, I want to hide, and then do the row number.

=IIF(ReportItems!textbox23.Value <> 0, RowNumber("table1_Group1"), Nothing)

Any way I can get same result and excluding hidden rows?
0
Comment
Question by:holemania
  • 2
3 Comments
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
>I'm hoping for it to skip if the textbox23 is 0, since that's what I'm hiding.
If that's the Hidden/Visible logic, then then you should be able to pull off a 'count of grouped rows' with an expression like SUM(IIF(textbox23 > 0, 1, 0)).
0
 

Author Comment

by:holemania
Comment Utility
When I use that expression, I'm getting the following error.

"The Value expression for the textbox 'textbox63' uses an aggregate function on a report item.  Aggregate functions can be used only on report items contained in page headers and footers."
0
 

Accepted Solution

by:
holemania earned 0 total points
Comment Utility
Since i want to hide anything with a value of zero field, it was done from sql instead of hiding it from SSRS since my row count is still counting those values with zeros.

As proof that this was done by sql script, here's a portion of the sql script that solved my issue.  

Basically, I was doing the running value from within SSRS.  If there's allocation, my user does not want to see the line item, and set shortage to a value of 0.  I am hiding those lines, but when I do my row count, it is also counting the hidden rows.  So it would be like row 1, 2, skip 3 since it's hidden, but then all of a sudden row 3 which is really row 4 has a count of 4 instead of the expected row 3 count.  I don't want my row count to include the hidden row and that's why i posted here to see if someone know a way.

Since I couldn't figure it out and the first suggestion didn't resolve my issue, I did my running value from within SQL, and then just filter it out if there's allocation and not a shortage.  This is the filter.

     AND      (T1.QTY_ON_HAND - RT.RUNNING_VALUE) < 0 --IF ALLOCATION, NO SHORTAGE, DO NOT SHOW


WITH CTE
AS
(
SELECT	DESIRED_RLS_DATE, WORKORDER_BASE_ID, WORKORDER_LOT_ID,
		WORKORDER_SUB_ID, PART_ID, DESCRIPTION, FABRICATED, 
		PURCHASED, CONSUMABLE, QTY_PER, CALC_QTY, ISSUED_QTY,
		QTY_IN_DEMAND, QTY_ON_ORDER, QTY_ON_HAND, BASE_ID, LOT_ID,
		WO_DUE_DATE, BUYER, TYPE, VENDOR_NAME, PO_WO_QTY_ON_ORDER, 
		CONSUME, BUYER_USER_ID,
		
		ROW_NUMBER() OVER (PARTITION BY PART_ID ORDER BY DESIRED_RLS_DATE, WORKORDER_BASE_ID, WORKORDER_SUB_ID) RN

FROM	@SHORTAGE_TEMP	
)

SELECT	T1.DESIRED_RLS_DATE, T1.WORKORDER_BASE_ID, T1.WORKORDER_LOT_ID,
		T1.WORKORDER_SUB_ID, T1.PART_ID, T1.DESCRIPTION, T1.FABRICATED, 
		T1.PURCHASED, T1.CONSUMABLE, T1.QTY_PER, T1.CALC_QTY, T1.ISSUED_QTY,
		T1.QTY_IN_DEMAND, T1.QTY_ON_ORDER, T1.QTY_ON_HAND, T1.BASE_ID, T1.LOT_ID,
		T1.WO_DUE_DATE, T1.BUYER, T1.TYPE, T1.VENDOR_NAME, T1.PO_WO_QTY_ON_ORDER,
		T1.CONSUME, T1.BUYER_USER_ID, (T1.QTY_ON_HAND - RT.RUNNING_VALUE) QTY_SHORT
		
FROM	CTE T1

		CROSS APPLY
		(
		SELECT	ISNULL(SUM(T2.CALC_QTY - T2.ISSUED_QTY), 0) RUNNING_VALUE
		FROM	CTE T2
		WHERE	T2.PART_ID = T1.PART_ID
				AND T2.DESIRED_RLS_DATE <= T1.DESIRED_RLS_DATE
				AND T2.RN <= T1.RN
		) RT

		LEFT OUTER JOIN
		(
		SELECT	T2.PART_ID, SUM(T2.CALC_QTY) CALC_QTY, SUM(T2.ISSUED_QTY) ISSUED_QTY
		FROM	@SHORTAGE_TEMP T2
		GROUP BY T2.PART_ID
		) X ON X.PART_ID = T1.PART_ID


WHERE	(X.CALC_QTY - X.ISSUED_QTY) > T1.QTY_ON_HAND --INCLUDE MATERIALS SHORT
		AND	(T1.QTY_ON_HAND - RT.RUNNING_VALUE) < 0 --IF ALLOCATION, NO SHORTAGE, DO NOT SHOW
		AND (T1.WORKORDER_BASE_ID = @WO)

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now