Solved

SSRS - Row Number excluding hidden rows

Posted on 2014-11-07
3
688 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 4 178
Change the SSRS datasource server or connection string 10 58
SSRS Highlight Specific Column 3 68
Unable to save view in SSMS 21 73
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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