Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SSRS - Row Number excluding hidden rows

Posted on 2014-11-07
3
Medium Priority
?
912 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
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…
Loops Section Overview

971 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