Parameter in calculated field syntax error

Hi,

I’m encountering an error while creating a calculated field that uses a parameter. The error message is: “Expression {{argumentName}} for function {{functionName}} has incorrect argument type {{incorrectArgumentType}}. Function syntax expects {{functionSignature}}.”

Here’s what I’m trying to achieve:

  1. I have a parameter that acts as a filter for the last 20 trailing weeks (weeks 16-35)

  2. This parameter is connected to week number column from my dataset

  3. When a user selects a week, I want to calculate:

    • The year-over-year difference for the selected week (2025 vs 2024)

    • The year-over-year difference for the previous week

    • Then subtract these two differences

Here’s my current formula:

(
    sum(ifelse({year} = 2025 and {week} = ${Week1}, {value}, 0)) - 
    sum(ifelse({year} = 2024 and {week} = ${Week1}, {value}, 0))
) - 
(
    sum(ifelse({year} = 2025 and {week} = ${Week2}, {value}, 0)) - 
    sum(ifelse({year} = 2024 and {week} = ${Week2}, {value}, 0))
)

Can you help me identify what’s causing the error and how to fix it?

Hi @auripol and welcome to the Quick Sight community!
I understand what you’re trying to do but there are other functions available that may assist with this type of requirement a bit easier.
Here is some documentation to review regarding period over period computations; there are various ways to handle this based on what works best for your data/scenario.
Based on your scenario, there can be issues with the periodOverPeriodDifference; if so I would suggest looking further into the lag function; the second document below is a prior community post that discusses the use of it further.

Let me know if one of these options works towards your case or if you have any additional questions

Hi @auripol,

Following up here as it’s been awhile since we last heard from you; did you have any additional questions regarding your initial post or were you able to find a work around in the interim?

If we do not hear back within the next 3 business days, I’ll close out this topic.

Thank you!

Hi @auripol,

Since we have not heard back, I’ll go ahead and close out this topic. However, if you have any additional questions, feel free to create a new post in the community.

Thank you