SSRS Expressions

  • Good day experts,

    i have a task to set back ground color to my table.the conditions are if Column LastydiffBackupdate is less 2 days then color the column green.If more than two days color red, here is the code which worked fine.=IIf(DateDiff("d",Fields!LastDiffBackupDate.Value, Today())<2,"Green","Red")

    now i must set another colour experssion to the same column for if it is null then no color.

    My question is how can i add another iff statement to the one above.

    I am trying this this not working =IIf(DateDiff("d",Fields!LastDiffBackupDate.Value, Today())<2,"Green","Red") OR IIf(IS Nothing(Fields!LastDiffBackupDate.Value),"Transparent").

    Please help!!

  • =IIf(DateDiff("d",Fields!LastDiffBackupDate.Value, Today())<2,"Green","Red") OR IIf(IS Nothing(Fields!LastDiffBackupDate.Value),"Transparent").

    You're almost there, but not quite. You have nest the iif's, so it would become:

    =IIf(DateDiff("d",Fields!LastDiffBackupDate.Value, Today()) < 2,"Green", IIf(Fields!LastDiffBackupDate.Value is Nothing,"Transparent","Red"))

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thank you so much but please i do not understand the < in the expression.Sorry i am new to Sql.

    =IIf(DateDiff("d",Fields!LastDiffBackupDate.Value, Today())<2,"Green", IIf(IS Nothing(Fields!LastDiffBackupDate.Value),"Transparent","Red"))

    Below are the conditions to be met by the expression.

    1.if the column lastdiffbackupdate value is within last two days then color green or else red meaning the red will only apply if the lastbackupdiffdate is three days and above.

    2.if that same column again is null then the color must be transparent because i have other databases that are set not to do Diff backups at all.

    I hope i clarified it clearly

    Regards

  • I do not understand the <2,

  • i dont know what is happening,the code you send me is having an uncommon symbol after Today()),but when i am replying it shows < symbol.

  • tmmutsetse (5/12/2016)


    i dont know what is happening,the code you send me is having an uncommon symbol after Today()),but when i am replying it shows < symbol.

    The less <2 is from your own logic that you provided to check if the date is within the last two days. An iif statement must have a Boolean result, if you remove the <2 you won't have a boolean expressions and won't be testing for anything.

    Also, apologies, i didn't actually check your syntax on the true/false logic, I have corrected.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • I am not seeing the corrections bru

    thanks

  • I correct my previous post, but repasted:

    =IIf(DateDiff("d",Fields!LastDiffBackupDate.Value, Today()) < 2,"Green", IIf(Fields!LastDiffBackupDate.Value is Nothing,"Transparent","Red"))

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply