1

I am trying to write a formula that would calculate a discounted cost depending on the date.

Any costs that accrue after May 2019 would have a discount rate of 7% and anything prior to that would be 6%.

This is what I have for the formula but it's saying the syntax is incorrect. Any help would be much appreciated.

ifelse(month >= 5 AND year >= 2019), then {unblended_cost} - ({unblended_cost} * 0.07), else {unblended_cost} - ({unblended_cost} * 0.06))
Amit Baranes
  • 7,398
  • 2
  • 31
  • 53

1 Answers1

3

Try the following and let me know if you encounter other errors

ifelse(                                                                         
  month >= 5 AND year >= 2019,                                                  
  {unblended_cost} - ({unblended_cost} * 0.07),                                 
  {unblended_cost} - ({unblended_cost} * 0.06)                                  
) 

Essentially ifelse can be thought of as a single function, and the then and else keywords are extraneous.

mjgpy3
  • 8,597
  • 5
  • 30
  • 51
  • Yes this worked out perfectly. Thanks! It’s weird the way that they format their SQL queries –  Nov 06 '19 at 22:28
  • Function documentation here - https://docs.aws.amazon.com/quicksight/latest/user/ifelse-function.html – don Nov 11 '19 at 18:23