title: Need input on calculated field formula with if else condition in AWS Quicksight
body: <p>So, I have a use case where I need to calculate the monthly costs of my clients Quicksight usage.
  If the user has an 'Author' role the cost is fixed to 18$ per month. If the user has 'Reader' access, it costs 0.30cents for 30 minutes for the first 17 sessions and 5$ fixed rate if the usage exceeds 17 sessions.(How I calculated the number of sessions is another story).
  So, say I have a visual like this:
  <a href="https://i.stack.imgur.com/3jJHy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3jJHy.png" alt="enter image description here" /></a></p>
  <p>I redacted the user names for obvious reasons. I just want to add a simple calculated field called total_cost with following code:</p>
  <pre><code>    ifelse(role = 'Author', 18,ifelse(role = 'Reader' AND {total_sessions_per_month} &gt;= 17, 5,ifelse(role = 'Reader' AND {total_sessions_per_month} &lt; 17, 0.30*{total_sessions_per_month}
  , 0)))
  </code></pre>
  <p>I am getting a syntax error with this code. It says, <code>&quot;The syntax of the calculated field expression is incorrect. Correct the syntax and choose Create again.&quot;</code></p>
  <p>Also, I am not entirely sure about the logic of the code here, as the field 'total_sessions_per_month' is another aggregated field.</p>
  <pre><code>sumOver(sum({total_sessions}),[{user_name},role,year,month])
  </code></pre>
  <p>I don't know how it fits here, as I formed a condition with an non-aggregated field(role) and aggregated field(total_sessions_per_month).</p>
  <p>I hope someone can help me figure this out, as I am pretty new to Quicksight and BI in general.</p>