1

I think I've found a bug in SSRS or maybe I'm missing something.

Basically if I use a lookup in a text box between two charts, the legend values in the second chart are incorrect, the lookup function will not find a unqiue match but that 'should' be OK as the documentation says it will return the first value. In fact the textbox that uses the lookup is returning what I would expect, it's the chart that immediately follows it that goes wrong.

I'll start with the result and then briefly cover how to reproduce this.

In the image below you will see 2 pie charts, the first is filtered (via the Chart filters) on Chart =1 and the second on Chart =2 . They both get their data from the same dataset (dsCharts), the results of which are shown in the table below the charts.

On the second chart I added some more values to the legend so I can see exactly which record is being shown but this was only after I spotted the issue, the default legend properties still show this issue.

This was built using VS2015 and SSRS 2016. The deployed version also shows the same bug so it's not just a Visual Studio thing.

enter image description here

The top legend entry in the 2nd chart should show "Mega brand" but it's showing the last entry from the chart above. The actual pie data is correct (48%)

The green text boxes use a lookup and, if the lookup does not get a unqiue value this issue occurs.

If I move the text box below the 2nd chart it works as expected.

enter image description here

The LOOKUP function is as follows..

=LOOKUP(2, Fields!Chart.Value, Fields!Title.Value, "dsCharts")

As you can see this will not return a unique value (that's OK though andf the correct value is being returned).

If I change the lookup to return a unique value like this...

=LOOKUP(3, Fields!Chart.Value + Fields!rnk.Value, Fields!Title.Value, "dsCharts")

The everything works. (Above is just adding chart and rnk colums so three will always get the first title from the chart 2 rows)

In summary: if I move the text box below the 2nd chart it works just fine. If I change the lookup to get a unique value it also works fine.

THE QUESTION

Am I missing something here? This certainly does not feel like a 'by-design feature".

The link below is the RDL in case anyone wants to test it. (You'll need to change the connection info to an actual server/database but other than that it should just work.

https://1drv.ms/u/s!AvWOxxoIjY1UlxJBS7uwiAc4godK

Here's the SQL to create the dataset dsCharts in case you want to start from scratch.

DECLARE @t TABLE (CHart int, SegID int, Caption varchar(50), PeriodID int, PeriodDesc varchar(10), Title varchar(50), Others int, Amount float, rnk int, PcShare float)
INSERT INTO @t VALUES
(1, 4, 'Mega Brand', 2017000, '2017', 'Top 5 Brands Volume Share, 2017', 0, 2641.02756210156, 1, 0.4486715547),
(1, 5, 'Big Brand', 2017000, '2017', 'Top 5 Brands Volume Share, 2017', 0, 887.87929700944, 2, 0.1508375718),
(1, 311, 'Average Brand', 2017000, '2017', 'Top 5 Brands Volume Share, 2017', 0, 405.48776698076, 3, 0.0688863794),
(1, 3, 'Mediocre Brand', 2017000, '2017', 'Top 5 Brands Volume Share, 2017', 0, 399.3852463092, 4, 0.0678496513),
(1, 297, 'Some other brand', 2017000, '2017', 'Top 5 Brands Volume Share, 2017', 0, 264.67433915592, 5, 0.0449642589),
(1, 148, 'Cheap stuff', 2017000, '2017', 'Top 5 Brands Volume Share, 2017', 0, 342.83011182646, 8888, 0.0582417697),
(1, 141, 'Others', 2017000, '2017', 'Top 5 Brands Volume Share, 2017', 1, 945.042844878088, 9999, 0.1605488138),
(2, 4, 'Mega-Brand', 2017000, '2017', 'Top 5 Brands Value Share, 2017', 0, 4231.13539284372, 1, 0.4825376523),
(2, 5, 'Big-Brand', 2017000, '2017', 'Top 5 Brands Value Share, 2017', 0, 1311.73933399895, 2, 0.1495966354),
(2, 311, 'Average Brand', 2017000, '2017', 'Top 5 Brands Value Share, 2017', 0, 675.765818425164, 3, 0.077067364),
(2, 3, 'Mediocre Brand', 2017000, '2017', 'Top 5 Brands Value Share, 2017', 0, 561.11919104568, 4, 0.0639925485),
(2, 286, 'Smaller brand', 2017000, '2017', 'Top 5 Brands Value Share, 2017', 0, 398.869530857333, 5, 0.0454888698),
(2, 148, 'Cheap stuff', 2017000, '2017', 'Top 5 Brands Value Share, 2017', 0, 398.733393643842, 8888, 0.0454733441),
(2, 141, 'Others', 2017000, '2017', 'Top 5 Brands Value Share, 2017', 1, 1191.14560398701, 9999, 0.1358435857)

SELECT * FROM @t

To reproduce the layout must be as in the images above, the lookups in the two text boxes are as stated above but the first one uses 1 as the lookup value (1st function parameter) instead of 2.

Alan Schofield
  • 19,839
  • 3
  • 22
  • 35
  • Just FYI in case you didn't realize: there are embedded images in that RDL file, I don't know if you might want to remove those from your download link. Maybe it isn't a big deal to you if they're there or not, they don't look like they're too revealing of anything, but just a heads up. I removed them on my end and reproduced the same results. – C Black Sep 14 '18 at 16:24
  • Thanks @CBlack. I'll remove those. It's not a big deal but you know what these copyright marking people are like ! :) I'm glad you could reproduce it too, at least I know it's not something messed up at my end. – Alan Schofield Sep 14 '18 at 16:31
  • Also, this doesn't really answer the question but it may be worth noting, changing the `LOOKUP` in the second textbox to `LOOKUPSET` and explicitly grabbing the first element of that array does not result in the same issue on my end. `=LOOKUPSET(2, Fields!Chart.Value, Fields!Title.Value, "dsCharts")(0)` – C Black Sep 14 '18 at 16:35
  • So actually, when I use your RDL file I am able to reproduce your results, but when I quickly re-create the report myself I am not able to reproduce your results. So I guess there is _something_ somewhere in the RDL causing that to happen, but either way it still _shouldn't_ be happening. [Report output](https://i.stack.imgur.com/hEHOH.png), [Report design](https://i.stack.imgur.com/mySYz.png) with the expression in the second textbox being `=Lookup(2, Fields!CHart.Value, Fields!Title.Value, "dsCharts")` – C Black Sep 14 '18 at 16:57
  • Interesting. Did you filter each chart? Could you send me your RDL so I can compare (then I will leave you in peace!) – Alan Schofield Sep 14 '18 at 22:59
  • Yep each chart is filtered the same way (or at least should be). I didn't save the report earlier, so this is another quick re-creation, hopefully I didn't miss anything. [Dropbox link](https://www.dropbox.com/s/bpnvv62sgfv6d0r/Lookup%20Bug%20Recreation.rdl?dl=0) – C Black Sep 15 '18 at 00:21
  • Many thanks I'll check it tomorrow – Alan Schofield Sep 15 '18 at 00:23

0 Answers0