# Condition not working as expected in If Else function

**URL:** <https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640>\
**Category:** Q&A\
**Tags:** tables, calculations, analysis, Business-Intelligence-Engineer, quick-sight\
**Created:** [June 21, 2024, 10:54am UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640 "2024-06-21T10:54:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdr\_Dinesh](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@tdr\_Dinesh](https://community.amazonquick.com/u/tdr_Dinesh)\
**Post date:** [June 21, 2024, 10:54am UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/1 "2024-06-21T10:54:46Z")

</div>

Hi Team,

I am not sure, what is the issue is here. Initially, I have written a calculated filed and it is working as expected (Reference snap 1 & 2), however I would like to add couple of conditions to the existing calculated field (Refer Snap 3), after writing the rules, I am getting below error message, as shown in Snap 4. Could someone please assist me with this issue?. Thank you!

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/7/5/759a08374c658cdba8ffb1b6a4c5f80e07fe1db7.png)

![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/f/2/f2b716a1d74ec2fa5da50d49efb3374dec0a6b05.png)

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/0/8/08140fd4ea0877f6d93b9ea1ccffbf98336801bf.png)  
 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/f/8/f85c69386ab7628a9307b584177a8b926add8f3a.png)

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [June 21, 2024, 2:55pm UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/2 "2024-06-21T14:55:51Z")

</div>

Hi @tdr_Dinesh,  
This is interesting as your calculated field looks to be written out correct.  
A couple questions in reference to this…  
Are you creating this field on the dataset or analysis layer?  
Are you running SPICE or direct query?  
Is ‘overdue’ a calculated field as well (if so, could you share)?

It’s very possible that just refreshing the page and recreating the calculated field could help as well. Normally adding one extra ‘ifelse’ condition shouldn’t keep it from running.

Thank you!

---

<div class="post-metadata">

**Author:** ![tdr\_Dinesh](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@tdr\_Dinesh](https://community.amazonquick.com/u/tdr_Dinesh)\
**Post date:** [June 21, 2024, 3:07pm UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/3 "2024-06-21T15:07:59Z")

</div>

Hi @Brett,

Would you please have a look into the below comments.

Are you creating this field on the dataset or analysis layer? - Created on the analysis Layer.  
Are you running SPICE or direct query? - Direct Query  
Is ‘overdue’ a calculated field as well (if so, could you share)? - Yes, it is a calculated field.

We have refreshed the page and recreated the calculated field, but no luck.

![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/6/b/6bf1f3b873bf8c77680106abf4520ed3cc1f9401.png)

Thank you!

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [June 21, 2024, 3:29pm UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/4 "2024-06-21T15:29:06Z")

</div>

Hi @tdr_Dinesh,  
I wonder if it may have something to do with your greater/less than statements. What if you tried the following instead:  
OverDue \>0 AND OverDue \<=5  
OverDue \>=6 AND OverDue \<=10  
OverDue \>=11 AND OverDue \<16

In your statement, you’re not accounting for 5 anywhere as you have ‘less than’ in your first line and ‘greater than’ in the second line.

---

<div class="post-metadata">

**Author:** ![tdr\_Dinesh](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@tdr\_Dinesh](https://community.amazonquick.com/u/tdr_Dinesh)\
**Post date:** [June 21, 2024, 3:41pm UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/5 "2024-06-21T15:41:46Z")

</div>

Hi @Brett ,

No Luck, still experiencing the same issue. Could you please have a look in to the below snapshot. Thank you!

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/d/8/d8c809e037d7da260cba9ffbcda728d50157303a.png)

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [June 21, 2024, 4:13pm UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/6 "2024-06-21T16:13:58Z")

</div>

Hi @tdr_Dinesh,  
Is it a requirement to utilize direct query for the dataset? Would hourly or even 15 minute refreshes still meet the expectations for the dashboard?

Depending on the database you’re querying, the number of calculated fields you are using, and the complexity of the SQL statement that is building the dataset, it seems like this one change is causing the query to timeout.

Would you be able to move the calculated fields from the analysis to the custom SQL statement on ingestion or possibly even try to add them into the dataset directly? I would also be curious to see if the error went away on a duplicate dataset that is set to SPICE.

---

<div class="post-metadata">

**Author:** ![tdr\_Dinesh](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@tdr\_Dinesh](https://community.amazonquick.com/u/tdr_Dinesh)\
**Post date:** [June 25, 2024, 10:55am UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/7 "2024-06-25T10:55:49Z")

</div>

Hi @Brett ,

Yes, it is a requirement to update the incremental changes every 5 minutes. Most of the calculated fields are added directly to the dataset, while only a few are created at the analysis level.

Thank you!

---

<div class="post-metadata">

**Author:** ![Sanjeeb2022](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/sanjeeb2022/32/20947_2.png) [@Sanjeeb2022](https://community.amazonquick.com/u/Sanjeeb2022)\
**Post date:** [June 25, 2024, 5:20pm UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/8 "2024-06-25T17:20:38Z")

</div>

Hi @tdr_Dinesh - are you getting the error immediately or after sometime of the execution. Also what is the data source and what is the volume of data for the direct query?

Also when this is timing out, is it possible to generate the extract sql execute in the source db. This will give some details around the sql generated by QS.

Regards - Sanjeeb

---

<div class="post-metadata">

**Author:** ![tdr\_Dinesh](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@tdr\_Dinesh](https://community.amazonquick.com/u/tdr_Dinesh)\
**Post date:** [June 26, 2024, 11:40am UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/9 "2024-06-26T11:40:37Z")

</div>

Hi @Sanjeeb2022 ,

Yes, we are getting the error message immediately, and the data source is Athena. Currently, we have around 135,000 records in the dataset.

Thank you!

---

<div class="post-metadata">

**Author:** ![Xclipse](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/xclipse/32/20455_2.png) [@Xclipse](https://community.amazonquick.com/u/Xclipse)\
**Post date:** [June 28, 2024, 5:30am UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/10 "2024-06-28T05:30:29Z")

</div>

Thank you for letting us know. I would recommend filing a case with AWS Support where we can dive into the details so that we can help you further. Here are the steps to [open a support case](https://docs.aws.amazon.com/awssupport/latest/user/case-management.html). If your company has someone who manages your AWS account, you might not have direct access to AWS Support and will need to raise an internal ticket to your IT team or whomever manages your AWS account. They should be able to open an AWS Support case on your behalf. Hope this helps!

---

<div class="post-metadata">

**Author:** ![Xclipse](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/xclipse/32/20455_2.png) [@Xclipse](https://community.amazonquick.com/u/Xclipse)\
**Post date:** [June 28, 2024, 5:31am UTC](https://community.amazonquick.com/t/condition-not-working-as-expected-in-if-else-function/31640/11 "2024-06-28T05:31:11Z")

</div>

Archived on June 28, 2024, 5:31am UTC


