# Using If/Then

**URL:** <https://www.epiusers.help/t/using-if-then/42890>\
**Category:** Epicor ERP 10\
**Created:** [February 19, 2018, 5:44pm UTC](https://www.epiusers.help/t/using-if-then/42890 "2018-02-19T17:44:22Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will79](https://www.epiusers.help/letter_avatar_proxy/v4/letter/w/ea666f/32.png) [@Will79](https://www.epiusers.help/u/Will79)\
**Post date:** [February 19, 2018, 5:44pm UTC](https://www.epiusers.help/t/using-if-then/42890/1 "2018-02-19T17:44:22Z")

</div>

I have a list of 13 part groups that I am trying to use an If/Then statement to tell me which ones have zero’s in them for the particular customer. What I am running into is it’ll read the ones until it finds a zero then display what’s it’s supposed but it doesn’t keep reading and finish of the list. Can an If/Then be made to do this, or no?

Example:

Demo=0 Trans=1 Services=0 Patriot=0

Should display: Demo Services Patriot Instead just it displays Demo.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [February 19, 2018, 5:53pm UTC](https://www.epiusers.help/t/using-if-then/42890/2 "2018-02-19T17:53:38Z")

</div>

Please provide the code so we can look at what you are trying to do ?

-Jose

---

<div class="post-metadata">

**Author:** ![Will79](https://www.epiusers.help/letter_avatar_proxy/v4/letter/w/ea666f/32.png) [@Will79](https://www.epiusers.help/u/Will79)\
**Post date:** [February 19, 2018, 5:59pm UTC](https://www.epiusers.help/t/using-if-then/42890/3 "2018-02-19T17:59:29Z")

</div>

case  
when Demo1 = 0 then ‘Demo’  
when Trans1 = 0 then ‘Trans’  
when Service2 = 0 then ‘Services’  
when Fours2 = 0 then ‘400’  
when Patriot2 = 0 then ‘Patriot’  
when KeyTags2 = 0 then ‘Key Tags’  
when Decal2 = 0 then ‘Decal’  
when Mirror2 = 0 then ‘Mirror’  
when Slogan2 = 0 then ‘Slogan’  
when Vehicle2 = 0 then ‘Vehicle’  
when Consecu2 = 0 then ‘Consecu’  
when Flour2 = 0 then ‘Flour’  
when Sun2 = 0 then ‘Sun’  
else ‘’  
end

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [February 19, 2018, 6:04pm UTC](https://www.epiusers.help/t/using-if-then/42890/4 "2018-02-19T18:04:31Z")

</div>

This is working as designed , a case statement once a condition is true the case statement is done and breaks out.

-Jose

---

<div class="post-metadata">

**Author:** ![Will79](https://www.epiusers.help/letter_avatar_proxy/v4/letter/w/ea666f/32.png) [@Will79](https://www.epiusers.help/u/Will79)\
**Post date:** [February 19, 2018, 6:07pm UTC](https://www.epiusers.help/t/using-if-then/42890/5 "2018-02-19T18:07:23Z")

</div>

That’s what I was thinking. So thoughts on how to achieve what I am looking for?

---

<div class="post-metadata">

**Author:** ![Will79](https://www.epiusers.help/letter_avatar_proxy/v4/letter/w/ea666f/32.png) [@Will79](https://www.epiusers.help/u/Will79)\
**Post date:** [February 19, 2018, 6:20pm UTC](https://www.epiusers.help/t/using-if-then/42890/6 "2018-02-19T18:20:07Z")

</div>

BAsically I want to turn this

Customer Demo1 Trans1 Service2 Fours2 Patriot2 KeyTags2 Decal Mirror2 Slogan2 Vehicle Consecu Flour2 Sun2   
593 1 0 0 1 0 1 0 1 1 0 0 0 0  
925 1 0 0 0 0 0 0 0 0 0 0 0 0  
902 1 0 0 0 0 1 0 0 1 0 0 0 1  
23 1 0 0 0 0 0 0 0 0 0 0 0 0  
215 1 0 0 0 0 1 0 0 0 0 0 0 0  
710 1 0 1 1 0 1 0 1 1 0 0 0 0  
46 1 0 0 0 0 0 1 0 0 0 1 0 0  
401 1 0 0 1 0 1 1 1 1 1 0 0 1  
733 1 0 0 0 1 0 1 0 1 0 0 0 0  
192 1 0 1 1 0 1 0 1 1 0 1 0 0  
1520 0 0 0 0 0 0 1 0 0 0 0 0 0  
524 1 0 0 0 0 0 0 0 0 0 0 0 0  
1094 1 0 0 0 0 0 0 0 0 0 0 0 0

Into just the headings, Demo, Trans, fours, or any appropriate combination.

---

<div class="post-metadata">

**Author:** ![mlrainsford](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mlrainsford](https://www.epiusers.help/u/mlrainsford)\
**Post date:** [February 19, 2018, 6:21pm UTC](https://www.epiusers.help/t/using-if-then/42890/7 "2018-02-19T18:21:56Z")

</div>

I’m assuming that this is SQL based on your syntax, but in C# this could be accomplished with the use of a foreach loop in case I am mistaken.

As for SQL, I know this is ugly, but you could break each of the cases into its own calculated field and then combine into a final calculated field.

EX) This would be one of the calculated fields, called DemoString:

> CASE WHEN Demo1 = 0 then 'Demo’ ELSE ‘’ END

You would do this for each of the part groups. Then all the part strings would combine into the final calculated field called FinalString:

> DemoString + TransString + ServiceString + …

This could also all be done in one calculated field:

> CASE WHEN Demo1 = 0 then 'Demo’ ELSE ‘’ END + CASE WHEN Trans1 = 0 THEN ‘Trans’ ELSE ‘’ END + …

---

<div class="post-metadata">

**Author:** ![Will79](https://www.epiusers.help/letter_avatar_proxy/v4/letter/w/ea666f/32.png) [@Will79](https://www.epiusers.help/u/Will79)\
**Post date:** [February 19, 2018, 6:25pm UTC](https://www.epiusers.help/t/using-if-then/42890/8 "2018-02-19T18:25:45Z")

</div>

Yes,it is. It the SQL Editor in Epicor.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [February 19, 2018, 6:24pm UTC](https://www.epiusers.help/t/using-if-then/42890/9 "2018-02-19T18:24:20Z")

</div>

You are going to have to make a calculated field for each of those cases

-Jose

---

<div class="post-metadata">

**Author:** ![Will79](https://www.epiusers.help/letter_avatar_proxy/v4/letter/w/ea666f/32.png) [@Will79](https://www.epiusers.help/u/Will79)\
**Post date:** [February 19, 2018, 6:28pm UTC](https://www.epiusers.help/t/using-if-then/42890/10 "2018-02-19T18:28:51Z")

</div>

so change this (case when SubQuery2.Part\_RefCategory = ‘Demo’ then ‘1’ else ‘0’ end) to (case when SubQuery2.Part\_RefCategory = ‘Demo’ then ‘0’ else ‘’ end)  
Then in a serpate calulated filed do something like demo1+trans1+, etc, correct?

---

<div class="post-metadata">

**Author:** ![Will79](https://www.epiusers.help/letter_avatar_proxy/v4/letter/w/ea666f/32.png) [@Will79](https://www.epiusers.help/u/Will79)\
**Post date:** [February 19, 2018, 6:52pm UTC](https://www.epiusers.help/t/using-if-then/42890/11 "2018-02-19T18:52:36Z")

</div>

One more error, says Couldn’t store \<\> in Calculated\_Service Column. Expected type is Int32.

I’m thinking its all the + used in trying to connect the strings and those are not int data types.

---

<div class="post-metadata">

**Author:** ![mlrainsford](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mlrainsford](https://www.epiusers.help/u/mlrainsford)\
**Post date:** [February 19, 2018, 6:57pm UTC](https://www.epiusers.help/t/using-if-then/42890/12 "2018-02-19T18:57:07Z")

</div>

That error would come from your calculated field being set to Int instead of String. I thought you were trying to go from 0s and 1s to the string format?

> [@Will79](#):
>
> I have a list of 13 part groups that I am trying to use an If/Then statement to tell me which ones have zero’s in them for the particular customer. What I am running into is it’ll read the ones until it finds a zero then display what’s it’s supposed but it doesn’t keep reading and finish of the list. Can an If/Then be made to do this, or no?
> 
> Example:
> 
> Demo=0 Trans=1 Services=0 Patriot=0
> 
> Should display: Demo Services Patriot Instead just it displays Demo.

---

<div class="post-metadata">

**Author:** ![Will79](https://www.epiusers.help/letter_avatar_proxy/v4/letter/w/ea666f/32.png) [@Will79](https://www.epiusers.help/u/Will79)\
**Post date:** [February 19, 2018, 7:12pm UTC](https://www.epiusers.help/t/using-if-then/42890/13 "2018-02-19T19:12:23Z")

</div>

Got it to work! Thanks!
