Parameters, calculated fields and questions

I’m passing this query into the Quicksight calculated field and getting an error:

“At least one of the arguments in this function does not have the correct type”

The Parameter is used as a filter, this parameter calls the variable “product1” which is of type “measures” “product1” is an integer (All fields are measured)

ifelse(
${menu} = "product1", sum([{product1}]),
${menu} = "product2", avg([{product2)]),
null
)

I also tried it this way

ifelse(
${menu}, "product1", sum([{product1}]),
${menu}, "product2", avg([{product2)]),
null
)

Does anyone have an idea what it could be?

Hi @Bruna_olimpia and welcome to the Quick Sight community!
I believe that your error may be coming from a few errors with the formatting. The formula should look something like:

ifelse(
    ${menu} = "product1", sum({product1}),
    ${menu} = "product2", avg({product2}),
    NULL
    )

The brackets would come after the field but those would only be included if you’re looking to partition by another field. Also, you’ll want to make sure and always capitalize all of ‘NULL’.

This formula should work as long as your ‘product’ values are either an integer or #.

Let me know if you have any other questions!

3 Likes

I received the best welcome. Thank you so much!

1 Like