Hi guys, this is probably simple but I cannot work it out. I have a Union BAQ which works, but the data is not displaying in the order I expected it to, I have tried changing the order in the subquery list but I then get an error. basically, I want the Quotes (Top level) to display before the Orders (Union).
Hi Darius, thanks for the response. I am taking your advice and attempting a CTE query. I have done a bit of reading and I think I need three queries, a CTE, a Union All and a Top Level. My CTE looks like this,
Am I right in thinking that my Union All would basically be basically the same query joined to the CTE on the canvas?
What I’m after is to see all the Quotes with multiple orders attached in the format of, quote details line followed by orders attached detail lines then the next quote details line etc. Is this the way to do it? Can it even be done?
Thanks for your help.
My original query was a Union one which had a Top Level identical to the one above, with sales order fields set to null. The Union was the same query with the quote fields set to null. It worked ok when only one quote was returned, it displayed the quote data with all attached orders below, but when I tried more than one quote it displayed all the quote lines then all the order details below. I am trying to list quote, then attached orders (eventually with a sum of the order values), then the next quote with all attached orders, and so on. I did play around with advanced grouping but to no avail.
Hi Kevin, I tried what you suggested, but it’s still not looking how I want it to,
As you can see I have three quotes here. What I am trying to achieve is, line one showing the quote details, then on the lines below just the order numbers and values (not repeating the quote detail), then the next quote, followed by the order numbers and values, and so on.
yeah, what you are really looking for is a full outer join, you want to see all quotes with or with with out orders and you want to see any orders that do not have quotes. unfortunately, I have never been able to get the full outer join to work in a BAQ, so I think you were on the right track with the Union.
To answer question on the CTE: don’t change anything in the design of your “top level,” don’t change anything in your “Union All”. Simply change the Query top of your “top level” from “top level” to “CTE”.
then add a new subquery as a new top level. In the design pane for your new top level select one thing: that “CTE” query which was previously the top level.
display the fields you want in that top level, sort it the way you want and you should be good.
Ok, so I’m back on this today. I have reverted back to a Uninion query, which as you can see is returning three quotes, correctly, with all the related orders correctly, but they are not listed beneath the related quote as I want them. Like Quote, Related Orders, Quote, Related Orders, Quote, Related Orders.
Thanks Brandon, I replaced the null on the quote number in the Union query with the quote number and then I get what I’m after.
As a footnote, is it possible to sum the order value column for each quote, so we can quickly see the total value of orders against the quote?
you might be able to get fancy with some case statement to show the amount or not. But a number will not show empty, it will only show 0, so you would have to get even fancier with trying to use a character field and converting… Probably not work it.
I’m gonna remember that. I have a gl report I had to do a few func overs, that worked well until Oct 1, when Epicor decided to break some summary info out into extreme detail. Gonna have to start over and might need some help!