# Error Message | Data Preparation

**URL:** <https://community.amazonquick.com/t/error-message-data-preparation/31404>\
**Category:** Q&A\
**Tags:** error, data-source, calculations, Business-Intelligence-Engineer, quick-sight\
**Created:** [June 17, 2024, 11:10am UTC](https://community.amazonquick.com/t/error-message-data-preparation/31404 "2024-06-17T11:10:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JulianBr](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/julianbr/32/21857_2.png) [@JulianBr](https://community.amazonquick.com/u/JulianBr)\
**Post date:** [June 17, 2024, 11:10am UTC](https://community.amazonquick.com/t/error-message-data-preparation/31404/1 "2024-06-17T11:10:35Z")

</div>

Hi all,  
i am preparing a dataset and need to add calculated fields within the dataset.  
I already added a few and it works, but when i add the following, it throws the following **error message** :

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/1/e/1e25abbd0c491f43dfad108ee6f75b6fdd89cb36.png)

**The calculation i am adding is the following:**  
substring({problem\_description},  
locate({problem\_description}, 'Error text sgbd: ') + 17,  
ifelse(  
(contains ({problem\_description}, ‘Error message’) = ‘false’),  
(locate({problem\_description}, ‘Test Stand’)) - (locate({problem\_description}, 'Error text sgbd: ') + 17),  
(locate({problem\_description}, ‘Error message’)) - (locate({problem\_description}, 'Error text sgbd: ') + 17)  
))

I added similar calculations which work fine (but there are no ifelse-functions).

NOTE: This Calculation works fine in analysis. Only in Data-Set preparation the error occurs.

Can some please help me troubleshoot?  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![WLS-D](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/wls-d/32/36109_2.png) [@WLS-D](https://community.amazonquick.com/u/WLS-D)\
**Post date:** [June 17, 2024, 9:18pm UTC](https://community.amazonquick.com/t/error-message-data-preparation/31404/2 "2024-06-17T21:18:43Z")

</div>

Hello @JulianBr , welcome to the Quick Sight community!

Starting with the error message, what data source are you connecting to and are you performing any joins in Quick Sight? Also, are you using SPICE or direct query? My first thoughts here based on the error, but that this still works in the analysis is a few things: 1) There might be a limitation on what function you can do against the data source 2) Something is up with the data coming from your data source in Quicksight possibly because of a join and 3) You are able to achieve this in your analysis because the data is stored in SPICE.

You could also try breaking the calculation apart. So first create the ifelse statement and then try adding that to your substring calculation.

---

<div class="post-metadata">

**Author:** ![JulianBr](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/julianbr/32/21857_2.png) [@JulianBr](https://community.amazonquick.com/u/JulianBr)\
**Post date:** [June 18, 2024, 7:25am UTC](https://community.amazonquick.com/t/error-message-data-preparation/31404/3 "2024-06-18T07:25:19Z")

</div>

Hi @WLS-D,

the dataset comes via Amazon Athena.  
And no, currently this dataset is not joined. But the calculated field is set up to make a join to another dataset possible.

Query Mode is SPICE.

I tried only the ifelse statement and error occurs.

---

<div class="post-metadata">

**Author:** ![WLS-D](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/wls-d/32/36109_2.png) [@WLS-D](https://community.amazonquick.com/u/WLS-D)\
**Post date:** [June 18, 2024, 3:17pm UTC](https://community.amazonquick.com/t/error-message-data-preparation/31404/4 "2024-06-18T15:17:44Z")

</div>

Hey @JulianBr !

If you are getting the dataset from Athena I would recommend doing the calculation there in a view.
