Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SSRS - Row Number excluding hidden rows

Posted on 2014-11-07
3
Medium Priority
?
855 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 66

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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

730 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