# Problem with spaces in ifelse expression evaluation

**URL:** <https://community.amazonquick.com/t/problem-with-spaces-in-ifelse-expression-evaluation/2397>\
**Category:** Q&A\
**Tags:** calculations, quick-sight\
**Created:** [March 17, 2022, 6:49am UTC](https://community.amazonquick.com/t/problem-with-spaces-in-ifelse-expression-evaluation/2397 "2022-03-17T06:49:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SimonW](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SimonW](https://community.amazonquick.com/u/SimonW)\
**Post date:** [March 17, 2022, 6:49am UTC](https://community.amazonquick.com/t/problem-with-spaces-in-ifelse-expression-evaluation/2397/1 "2022-03-17T06:49:54Z")

</div>

I am using an ifelse statement to check whether a text field starts with a specific phrase. I cannot seem to get this to work and my guess is that the space in the text field might be non standard (ie. transcoding issue?). If I use an AND statement to compare words in the phrase one at a time (extracted using SUBSTRING) then it works fine, but if I use a space anywhere it fails. Any ideas?

---

<div class="post-metadata">

**Author:** ![Tatyana\_Yakushev](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/tatyana_yakushev/32/157_2.png) [@Tatyana\_Yakushev](https://community.amazonquick.com/u/Tatyana_Yakushev)\
**Post date:** [March 17, 2022, 5:37pm UTC](https://community.amazonquick.com/t/problem-with-spaces-in-ifelse-expression-evaluation/2397/2 "2022-03-17T17:37:38Z")

</div>

Copy/paste value from the data into the ifelse expression.

---

<div class="post-metadata">

**Author:** ![SimonW](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SimonW](https://community.amazonquick.com/u/SimonW)\
**Post date:** [March 18, 2022, 1:24am UTC](https://community.amazonquick.com/t/problem-with-spaces-in-ifelse-expression-evaluation/2397/3 "2022-03-18T01:24:52Z")

</div>

Thank you Tatyana. I had tried to copy the data from the preview table in data prep but this did not work. After your feedback I then went back to the source data in Excel, and the copy and paste does work from there.

---

<div class="post-metadata">

**Author:** ![Naveed](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/naveed/32/961_2.png) [@Naveed](https://community.amazonquick.com/u/Naveed)\
**Post date:** [March 18, 2022, 7:50am UTC](https://community.amazonquick.com/t/problem-with-spaces-in-ifelse-expression-evaluation/2397/4 "2022-03-18T07:50:28Z")

</div>

> [@SimonW](#):
>
> I am using an ifelse statement to check whether a text field starts with a specific phrase. I cannot seem to get this to work and my guess is that the space in the text field might be non standard (ie. transcoding issue?). If I use an AND statement to compare words in the phrase one at a time (extracted using SUBSTRING) then it works fine, but if I use a space anywhere it fails. Any ideas?
> 
> > [@](#):
> >
> > Copy/paste value from the data into the ifelse expression.

Hi,

You must us the string functions available in QS to remove unnecessary/unwanted spaces trim,ltrim and rtrim based on your requirements.

---

<div class="post-metadata">

**Author:** ![SimonW](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SimonW](https://community.amazonquick.com/u/SimonW)\
**Post date:** [March 21, 2022, 1:37am UTC](https://community.amazonquick.com/t/problem-with-spaces-in-ifelse-expression-evaluation/2397/5 "2022-03-21T01:37:46Z")

</div>

Trim won’t help here as the space is in the middle of a phrase. The issue is that the space must be a non standard space which makes my ifelse statement fail to match against the string.
