# BAQ help

**URL:** <https://www.epiusers.help/t/baq-help/95389>\
**Category:** Epicor ERP 10\
**Tags:** baq\
**Created:** [October 13, 2022, 2:24pm UTC](https://www.epiusers.help/t/baq-help/95389 "2022-10-13T14:24:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![StephenW](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@StephenW](https://www.epiusers.help/u/StephenW)\
**Post date:** [October 13, 2022, 2:24pm UTC](https://www.epiusers.help/t/baq-help/95389/1 "2022-10-13T14:24:26Z")

</div>

Hi All,

I have a BAQ that returns part from a selected vendor and displays the last PO date, I’ve been asked now to make it so that if a part from that vendor has not been ordered then the last PO date column should be blank, how do I make my calculated field to say if purchased before display last PO date if not then leave blank?

I’m assuming I need to use a condition in the calculated field but not sure of how to string it all together.

 ![image](https://www.epiusers.help/uploads/default/original/3X/1/b/1bfe5c82169e0b54f9a5941babdd55c23db5fa96.png)

---

<div class="post-metadata">

**Author:** ![StephenW](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@StephenW](https://www.epiusers.help/u/StephenW)\
**Post date:** [October 13, 2022, 2:45pm UTC](https://www.epiusers.help/t/baq-help/95389/2 "2022-10-13T14:45:26Z")

</div>

So far I’ve gotten this far but am getting an error.

 ![image](https://www.epiusers.help/uploads/default/original/3X/a/5/a5a5487a284b1aa903926d8690137866f5fd1ab0.png)

---

<div class="post-metadata">

**Author:** ![Matt\_Belshaw](https://www.epiusers.help/user_avatar/www.epiusers.help/matt_belshaw/32/24917_2.png) [@Matt\_Belshaw](https://www.epiusers.help/u/Matt_Belshaw)\
**Post date:** [October 13, 2022, 2:46pm UTC](https://www.epiusers.help/t/baq-help/95389/3 "2022-10-13T14:46:41Z")

</div>

This is the format of a case statement:

```auto
Case 
when SubQuery3.PartXRefVend_LeadTime <> 0 then SubQuery3.PartXRefVend_LeadTime
when SubQuery3.VendPart1_LeadTime <> 0 then SubQuery3.VendPart1_LeadTime
else 0
end

```

---

<div class="post-metadata">

**Author:** ![Vinaykamboj](https://www.epiusers.help/user_avatar/www.epiusers.help/vinaykamboj/32/14848_2.png) [@Vinaykamboj](https://www.epiusers.help/u/Vinaykamboj)\
**Post date:** [October 13, 2022, 3:07pm UTC](https://www.epiusers.help/t/baq-help/95389/4 "2022-10-13T15:07:09Z")

</div>

True should not be enclosed in character markers. Try without the apostrophy.

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [October 13, 2022, 3:14pm UTC](https://www.epiusers.help/t/baq-help/95389/5 "2022-10-13T15:14:56Z")

</div>

You can’t set another field in the calculated field, so on the else, you need to get rid of the field you are trying to set, and just make it null.

Depending on the field, you might not be able to make a date field null. You might have to case it to a character field to get that to work, and obviously that means losing some of the dateyness of the field, so that’s a tradeoff.

---

<div class="post-metadata">

**Author:** ![jgreenaway](https://www.epiusers.help/user_avatar/www.epiusers.help/jgreenaway/32/172_2.png) [@jgreenaway](https://www.epiusers.help/u/jgreenaway)\
**Post date:** [October 13, 2022, 3:17pm UTC](https://www.epiusers.help/t/baq-help/95389/6 "2022-10-13T15:17:03Z")

</div>

Can you share the diagram view of your BAQ? You might be able to make this work by changing the type of join to the PO detail table.

---

<div class="post-metadata">

**Author:** ![StephenW](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@StephenW](https://www.epiusers.help/u/StephenW)\
**Post date:** [October 13, 2022, 3:20pm UTC](https://www.epiusers.help/t/baq-help/95389/7 "2022-10-13T15:20:59Z")

</div>

Tried, still get same error

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [October 13, 2022, 3:21pm UTC](https://www.epiusers.help/t/baq-help/95389/8 "2022-10-13T15:21:49Z")

</div>

Also, orderdate can’t be “true”… This isn’t javascript.

---

<div class="post-metadata">

**Author:** ![StephenW](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@StephenW](https://www.epiusers.help/u/StephenW)\
**Post date:** [October 13, 2022, 3:25pm UTC](https://www.epiusers.help/t/baq-help/95389/9 "2022-10-13T15:25:18Z")

</div>

So I got to here and then got this error.

 ![image](https://www.epiusers.help/uploads/default/original/3X/e/2/e225ace89f8e9e57134ed76054b3fe471a607023.png)

So I tried ticking the Group by on the calc field and got a different error.

 ![image](https://www.epiusers.help/uploads/default/original/3X/d/e/de5b14587f4020137213383b5f7590887f4aea7d.png)

---

<div class="post-metadata">

**Author:** ![StephenW](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@StephenW](https://www.epiusers.help/u/StephenW)\
**Post date:** [October 13, 2022, 3:26pm UTC](https://www.epiusers.help/t/baq-help/95389/10 "2022-10-13T15:26:22Z")

</div>

😅 I’m trying

---

<div class="post-metadata">

**Author:** ![StephenW](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@StephenW](https://www.epiusers.help/u/StephenW)\
**Post date:** [October 13, 2022, 3:27pm UTC](https://www.epiusers.help/t/baq-help/95389/11 "2022-10-13T15:27:52Z")

</div>

Here is diagram of my Top Level and then my Subquery.

 ![image](https://www.epiusers.help/uploads/default/original/3X/0/f/0f74889d7c87fb5e2e6e2d5e5cc6e4fd736af9d3.png)

 ![image](https://www.epiusers.help/uploads/default/original/3X/7/9/79d2b895bb339cf75b0a3172bb87517f662c4145.png)

---

<div class="post-metadata">

**Author:** ![StephenW](https://www.epiusers.help/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@StephenW](https://www.epiusers.help/u/StephenW)\
**Post date:** [October 13, 2022, 3:39pm UTC](https://www.epiusers.help/t/baq-help/95389/12 "2022-10-13T15:39:14Z")

</div>

Got it! changed join type on my toplevel between PartPlant and SubQuery from matching “Rows from PartPlane and SubQuery2” to “All Rows from PartPlant and SubQuery2” and bingo it worked! Thank you very much

---

<div class="post-metadata">

**Author:** ![jgreenaway](https://www.epiusers.help/user_avatar/www.epiusers.help/jgreenaway/32/172_2.png) [@jgreenaway](https://www.epiusers.help/u/jgreenaway)\
**Post date:** [October 13, 2022, 5:32pm UTC](https://www.epiusers.help/t/baq-help/95389/13 "2022-10-13T17:32:20Z")

</div>

Glad it worked - happy to help!
