Calculating difference of 2 values using Calculated Fields

I am trying to calculate difference values between 2 columns in a table. If the difference is 5 or less then the value of the calculated field should be N if not Y.
I tried this

ifelse(

(amt1-amt2) > 5,

‘N’,

‘Y’)
but it doesn’t work. I get both N and Y.

Hi @gopinathpc,

If you create a calculated field for amt1-amt2 and add it to your visual, do you get correct results for the difference?

1 Like

I do get the value of amt1-amt2.
But I need to know the difference of amt1 and amt2, because amt1 or amt2 or both can be negative.
I see there’s an option for difference in calculated field, but not sure what the 3rd parameter should be.

difference (amt1,amt2) doesn’t work.

1 Like

Hello @gopinathpc, can you show me an example of how a calculation of amt1-amt2 looks when used in your table visual? That alone in a calculated field should return the difference between the 2 values.

You could even try sum(amt1) - sum(amt2) if that values seem a little off, but that should be necessary when used in a table. Then, once that works as anticipated, you have 2 options. You can use conditional formatting in the table to return something like a check mark or an x if the value is greater than 5 or not. Otherwise, we can wrap it in an ifelse statement. Either of those options should provide the result you are looking for.

1 Like

Hello @gopinathpc, since we have not heard back from you with any further questions, I will archive this topic. If you need further assistance resolving this issue, please post a new question in the community and include a link to this topic to provide relevant information. That will ensure you are at the top of the priority list for a response from one of our QuickSight experts. Thank you!