Understanding an expression

  • Came across this expression in a SSRS project

    =CDbl(Parameters!CategoryQuota.Value((Variables!IndextoCategoryQuota.Value)-1))

    I have managed to understand what its doing however I can't see the reason for using the -1 in the expression can anyone explain the syntax.

  • Is this syntax valid?

    Seems a bit odd to have Parameters!myParameter.value(expression).

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Probably CategoryQuota is a Multivalue Parameter. It's an array, so, the expression get a specific value in this Array.

    You can define Variables for different scope. I think that IndextoCategoryQuota is in Report Scope.

    It seems like this expression prepare something for Report header or footer.

  • ndiro (5/15/2014)


    Probably CategoryQuota is a Multivalue Parameter. It's an array, so, the expression get a specific value in this Array.

    You can define Variables for different scope. I think that IndextoCategoryQuota is in Report Scope.

    It seems like this expression prepare something for Report header or footer.

    Ah, that makes sense.

    The -1 might be present because the array of CategoryQuota is zero based, but the variable IndextoCategoryQuota starts at 1.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • You are absolutely right IndextoCategoryQuota is in a Group Variable Scope, and is for a matrix header row you can find the example at this location.

    http://technet.microsoft.com/en-us/library/ff487482(v=sql.105).aspx

    Its a Microsoft example the last comment from the last contributer sounds right as well CategoryQuota is a but multivalued parameter that gets its value from converting the values of a Quata Column to computed column using this expression in the dataset in this =CDbl(Fields!Quota.Value).

    Here is the expression that creates the @IndextoCategoryQuota Variable =Lookup(Fields!Category.Value,Fields!Category.Value,Fields!ID.Value,"CategoryQuotas")

    I am close but I still don't understand fullu why we need the -1 from the variable in the expression

    CDbl(Parameters!CategoryQuota.Value((Variables!IndextoCategoryQuota.Value)-1))

    the syntax is correct though since it is working

  • kingdonshel (5/15/2014)


    You are absolutely right IndextoCategoryQuota is in a Group Variable Scope, and is for a matrix header row you can find the example at this location.

    http://technet.microsoft.com/en-us/library/ff487482(v=sql.105).aspx

    Its a Microsoft example the last comment from the last contributer sounds right as well CategoryQuota is a but multivalued parameter that gets its value from converting the values of a Quata Column to computed column using this expression in the dataset in this =CDbl(Fields!Quota.Value).

    Here is the expression that creates the @IndextoCategoryQuota Variable =Lookup(Fields!Category.Value,Fields!Category.Value,Fields!ID.Value,"CategoryQuotas")

    I am close but I still don't understand fullu why we need the -1 from the variable in the expression

    CDbl(Parameters!CategoryQuota.Value((Variables!IndextoCategoryQuota.Value)-1))

    the syntax is correct though since it is working

    The -1 might be present because the array of CategoryQuota is zero based, but the variable IndextoCategoryQuota starts at 1?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • SSChampion

    I think you are right you would have to start at 0 when using the CategoryQuota since it is Multivalued and starts at 0 while IndextoCategoryQuota starts at 1.

    Thanks a lot to everyone who contributed on this post.

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

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