# Define the variable is it possible in calculated field or not

**URL:** <https://community.amazonquick.com/t/define-the-variable-is-it-possible-in-calculated-field-or-not/27399>\
**Category:** Q&A\
**Tags:** error, embedding, developer, quick-sight\
**Created:** [March 18, 2024, 5:16am UTC](https://community.amazonquick.com/t/define-the-variable-is-it-possible-in-calculated-field-or-not/27399 "2024-03-18T05:16:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinodkumarb](https://avatars.discourse-cdn.com/v4/letter/v/c67d28/32.png) [@vinodkumarb](https://community.amazonquick.com/u/vinodkumarb)\
**Post date:** [March 18, 2024, 5:16am UTC](https://community.amazonquick.com/t/define-the-variable-is-it-possible-in-calculated-field-or-not/27399/1 "2024-03-18T05:16:29Z")

</div>

Hi team please tell me like below calculated field will be work in calculated field or not

i have define the variable here but result one iam getting the error

please clarify

var last\_month= sum(ifelse(  
truncDate(‘MM’, date) = truncDate(‘MM’, addDateTime(-1, ‘MM’, now())),  
{Generated value},  
0  
))

var last\_to\_last\_month=sum(ifelse(  
truncDate(‘MM’, date) = truncDate(‘MM’, addDateTime(-2, ‘MM’, now())),  
{Generated value},  
0  
))

ifelse({last\_to\_last\_month}=0,1,({last\_month}-{last\_to\_last\_month})/{last\_to\_last\_month})

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [March 18, 2024, 5:47am UTC](https://community.amazonquick.com/t/define-the-variable-is-it-possible-in-calculated-field-or-not/27399/2 "2024-03-18T05:47:03Z")

</div>

Hi @vinodkumarb  
it’s not possible to define variables.  
You could create three different calculated field or use the full logic within one calculated field.  
BR

---

<div class="post-metadata">

**Author:** ![vinodkumarb](https://avatars.discourse-cdn.com/v4/letter/v/c67d28/32.png) [@vinodkumarb](https://community.amazonquick.com/u/vinodkumarb)\
**Post date:** [March 18, 2024, 5:58am UTC](https://community.amazonquick.com/t/define-the-variable-is-it-possible-in-calculated-field-or-not/27399/3 "2024-03-18T05:58:36Z")

</div>

okey @ErikG thanks for the quick reply  
it should be update in the future or it will be like that only  
becouse in tableau and power bi we have have alike that option variable define
