locked
SSRS report with image based on condition RRS feed

  • Question

  • I have report where the first column is image that I want to show/hide based on a condition. The image is just to indicate this is new updated row of data. The condition needs to check a date field and if the date fields is in last 30 days then I want to image to show otherwise hide.

    Anyone have any pointers of how best to check the date field (inspection_date) against today date and if it's in the last 30 days then for the image to appear.


    • Moved by Eric__Zhang Thursday, April 9, 2015 5:58 AM more relevant
    Wednesday, April 8, 2015 3:48 PM

Answers

  • Set the Visibility property of the image to an IIF expression based on the datediff function to get the true condition for the time period 30 days you are interested in.
    • Proposed as answer by Vicky_Liu Thursday, April 9, 2015 6:00 AM
    • Marked as answer by Vicky_Liu Thursday, April 16, 2015 1:06 AM
    Wednesday, April 8, 2015 3:58 PM
  • Hi Wass5,

    Per my understanding that you want show/hide the image based on the condition that when the date field is in last 30 days then will show the image or will hide, right?

    As Jingyang suggested that you can use the datadiff function in the expression in the visibility of the image properties to show and hide the image like below:
    =IIF(datediff("d",fields!Date.Value,now())<30,false,true)

    But this will leave blank space in the column1 when the image is hide, If you don't want to display the blank space you can add the same expression in the visibility if the entire column1 like below:

    You can also use expression below to do the same:
    =IIF(DateAdd("d",-31,today())>Fields!Date.Value,true,false)

    If you still have any problem, please feel free to ask.

    Regards,
    Vicky Liu


    Vicky Liu
    TechNet Community Support


    • Proposed as answer by Vicky_Liu Wednesday, April 15, 2015 1:19 AM
    • Marked as answer by Vicky_Liu Thursday, April 16, 2015 1:07 AM
    Thursday, April 9, 2015 6:46 AM

All replies

  • Set the Visibility property of the image to an IIF expression based on the datediff function to get the true condition for the time period 30 days you are interested in.
    • Proposed as answer by Vicky_Liu Thursday, April 9, 2015 6:00 AM
    • Marked as answer by Vicky_Liu Thursday, April 16, 2015 1:06 AM
    Wednesday, April 8, 2015 3:58 PM
  • Ok thanks let me give that a go.
    Wednesday, April 8, 2015 4:04 PM
  • Hi Wass5,

    Per my understanding that you want show/hide the image based on the condition that when the date field is in last 30 days then will show the image or will hide, right?

    As Jingyang suggested that you can use the datadiff function in the expression in the visibility of the image properties to show and hide the image like below:
    =IIF(datediff("d",fields!Date.Value,now())<30,false,true)

    But this will leave blank space in the column1 when the image is hide, If you don't want to display the blank space you can add the same expression in the visibility if the entire column1 like below:

    You can also use expression below to do the same:
    =IIF(DateAdd("d",-31,today())>Fields!Date.Value,true,false)

    If you still have any problem, please feel free to ask.

    Regards,
    Vicky Liu


    Vicky Liu
    TechNet Community Support


    • Proposed as answer by Vicky_Liu Wednesday, April 15, 2015 1:19 AM
    • Marked as answer by Vicky_Liu Thursday, April 16, 2015 1:07 AM
    Thursday, April 9, 2015 6:46 AM