Solved

SSRS - Row Number excluding hidden rows

Posted on 2014-11-07
3
644 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
ID: 40430282
>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
ID: 40430622
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
ID: 40460252
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PERFORMANCE OF SQL QUERY 13 66
Parsing the XML data to SQL Server 4 59
Help with SQL joins 9 43
Caste datetime 2 52
A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
Introduction In the following article I’ll be discussing and demonstrating several different ways of how images can be put on a report. I’m using SQL Server Reporting Services 2008 R2 CTP, more precisely version 10.50.1352.12, but the methods ex…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

28 Experts available now in Live!

Get 1:1 Help Now