I have a BAQ on the LaborDtl table. It has a calculated field “count(distinct(LaborDtl.EmployeeNum)” where it is returning on a job on an operation how many different resources recorded labor.
I would like for it to say “Multiple” if it is > 1 and the EmployeeNum if it is = 1.
I am just not able to wrap my head around how to display this.
ok so SubQuery2.Calculate_EmpCount is an INT so i would have to convert to a string. but then this gives me ‘Multiple’ or 1. I want to replace the 1 with the value of the employeeNum.
Oh I missed that! In this case you will need a 2 step query. Add in a third subquery that lists the labordetails without aggregating them into a count. So for jobs with multiple labor entries this subquery would return all the emp ids that it would normally count.
Then in your top level query, write a calculation that looks at the value like we just did. Instead of returning the count, return the linked value from the new subquery you just made.
Strangely I keep getting a server side error. I think it is from the “count distinct” part of your formula. But I can’t quite get it working. Either way, that code should get you close!
For some reason your group by fields are all greyed out on my end. Strange! Try adding the emp name to the subquery 5 group by only. That shouldn’t affect your count in subquery2. I linked my subquery 5 to subquery 2 at the top level using all the field available.
so I found the server error. I have some calculated fields doing division and there are some instances of dividing into and by zero. solved that with a case statement.
Under the Query Builder where you selected your Display Fields you can mark the fields to group your BAQ by
You will likely need to most of the fields as group by and anything else will need to be a calculated field (like summing unit prices or counting the total number of parts)