0

Have code to show or hide rows based on a value in one of the cells for that row (In SQL Reporting Services)

I either get all the results hidden or none of the results hidden

Tried this

=IIF(Fields!CommodityCode.Value = "BOP",False,True)

Field Name is correct and BOP is a valid value for the field

=IIF(Fields!CommodityCode.Value = "BOP",False,True)

When the value BOP is in the cell then that row should show. Any other rows where the value of that cell is NOT BOP should be hidden.

1
  • 1
    Try adding a filter at the dataset for CommodityCode = "BOP".
    – SS_DBA
    Commented Mar 25, 2019 at 16:47

1 Answer 1

-1

So the issue here is that your conditional is checking the entire dataset for BOP and not the specific cell. You'll want to modify your expression to the following.

=IIF(ReportItems!CommodityCode.Value = "BOP",False,True)

The ReportItems! should be followed by the name of the textbox that contains the CommodityCode field. So you'll basically only need to replace the CommodityCode with the textbox name. The .Value should stay there.

EDIT: Based on the comment below, it seems you simply need to add a parent group to your data that groups by CommodityCode. In the Row Groups, right click on the details group and click Add a parent group. Then, simply select the CommodityCode field as shown below.

image

After that, you usually need to remove sorting from the group properties because it adds a sorting field by default. I typically will add a page break between groups, as well.

8
  • The name of the textbox is CommodityCode Tried your version and got the same results as mine. I've been using code like this to hide rows in tables for years....
    – TSimon
    Commented Mar 25, 2019 at 16:08
  • @TSimon Ok, then my expression should work as you need it to. You're using Fields! when you need ReportItems!.
    – Steve-o169
    Commented Mar 25, 2019 at 16:09
  • If I do this , case when [InvMaster+].CommodityCode = 'BOP' Then 'Tim' else 'Colin' end as TheCode In my data query I can the successfully use =iif(Fields!TheCode.Value = "Tim",False,True) To Show / Hide the data
    – TSimon
    Commented Mar 25, 2019 at 16:25
  • @TSimon I'm not sure what that has to do with your question? Could you clarify why my solution doesn't work, if that's the case? Or what you are trying to achieve?
    – Steve-o169
    Commented Mar 25, 2019 at 16:55
  • I have no idea why your solution doesn't work. It seems to be a problem with the data - maybe the datatype. If I use a CASE statement in my data query and type in the exact same values for CommodityCode then I can use my IFF statement and it works. The datatype for CommodityCode is Char(4) I'm trying to create three Report tables, each of which will only show a list of items that have the same CommodityCode value. My master query generates a list of items, then I simply do a JOIN to the table that has the values for CommodityCode.
    – TSimon
    Commented Mar 25, 2019 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.