# Dynamic Report Image Based on Page Number

**URL:** <https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063>\
**Category:** Ignition\
**Created:** [September 14, 2022, 4:04pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063 "2022-09-14T16:04:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bluemonkey136](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bluemonkey136](https://forum.inductiveautomation.com/u/Bluemonkey136)\
**Post date:** [September 14, 2022, 4:04pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/1 "2022-09-14T16:04:51Z")

</div>

I am struggling to get the image to change based on what page the report is. Looking for any suggestions/workarounds.

I have a query data source "SOS\_IMG" that returns an img column from a MS SQL Server table as VARBINARY.

> SELECT img FROM SOS\_IMG WHERE sos\_id = ? ORDER BY sos\_page ASC

My KEY for the Image component is as follows:

`SOS_IMG[Page-1].img`

Idea is to have a table on the report with 5ish records per page. Each page has a supporting image based on what page is referenced from the SQL query.... hence "Page-1" above ^^. Each image record has an accompanying page number. Page - 1 to get the index reference correct. Not the prettiest way about it but its where I'm at right now.

Currently passing the "Page" built in key is working but only for the 1st page. I don't think it requests the image again for the 2nd page.

I was trying to figure out how to get the image to render inside of a table in the report so I could try and pass it dynamically that way, but I have had 0 luck.

My next solution is going to be to create multiple pages and multiple data sets constrained to the number of records per page, but I feel this may also easily break if there is too much or too little information.

---

<div class="post-metadata">

**Author:** ![obober](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/obober/32/67865_2.png) [@obober](https://forum.inductiveautomation.com/u/obober)\
**Post date:** [September 14, 2022, 5:23pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/2 "2022-09-14T17:23:43Z")

</div>

If you try to put the second image onto the first page, does it work as intended?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 14, 2022, 5:37pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/3 "2022-09-14T17:37:06Z")

</div>

If you can put all 5 images on the page(s) you can then hide the ones that don’t belong on that page number by making the visible property dynamic on the image.  
 ![RptPage](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/460a63058c736a166f0397b1515c99ab0f2c6562.png)

---

<div class="post-metadata">

**Author:** ![Bluemonkey136](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bluemonkey136](https://forum.inductiveautomation.com/u/Bluemonkey136)\
**Post date:** [September 14, 2022, 6:08pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/4 "2022-09-14T18:08:50Z")

</div>

I think it doesn’t. If I bump up the index by adding or subtracting it is only responding to the numbers I enter not the actually Page value it seems. Not sure if this only the outcome when previewing the report vs actually generating it.

---

<div class="post-metadata">

**Author:** ![Bluemonkey136](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bluemonkey136](https://forum.inductiveautomation.com/u/Bluemonkey136)\
**Post date:** [September 14, 2022, 6:09pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/5 "2022-09-14T18:09:24Z")

</div>

I will try this now if it doesn’t heap space error on me. Fingers crossed.

---

<div class="post-metadata">

**Author:** ![Bluemonkey136](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bluemonkey136](https://forum.inductiveautomation.com/u/Bluemonkey136)\
**Post date:** [September 14, 2022, 7:24pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/6 "2022-09-14T19:24:29Z")

</div>

For some reason using this method is making no image appear now. Tested the same formulas on screen as well to make sure they return true as well. And no errors.

I have made 5 overlapping image components on the report with correct references for the key. In the visible properties I have below:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/2/92439234cfca1212e8a0e6b430c212438f1d3af3.png)

But no luck when previewing just shows blank…

---

<div class="post-metadata">

**Author:** ![Bluemonkey136](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bluemonkey136](https://forum.inductiveautomation.com/u/Bluemonkey136)\
**Post date:** [September 15, 2022, 8:06pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/7 "2022-09-15T20:06:58Z")

</div>

Anyone have an idea as to why image wouldnt be showing using this method?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 15, 2022, 9:15pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/8 "2022-09-15T21:15:17Z")

</div>

I’m not sure as it worked for me.  
Are you still including the image in the query and displaying it from there?  
That is the only thing I can think of.

---

<div class="post-metadata">

**Author:** ![Bluemonkey136](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bluemonkey136](https://forum.inductiveautomation.com/u/Bluemonkey136)\
**Post date:** [September 16, 2022, 7:25pm UTC](https://forum.inductiveautomation.com/t/dynamic-report-image-based-on-page-number/64063/9 "2022-09-16T19:25:50Z")

</div>

Yea my data source, “SOS\_IMG”, is just a SQL query returning a dataset with one column, “img”, being the img as VARBINARY data type from SQL. Looks as follows for each image component:

img shape 1 key: SOS\_IMG[0].img  
img shape 2 key: SOS\_IMG[1].img  
so on so forth for 3 more.

If I change the key back to static for the visible field and the box is checked it will show the image.

This is quite the roadblock on the project for me unfortunately. I’m also considering just saving the XML and seeing if finding a viewer for it will show the images because all of the byte data still shows on an export for each image.
