Hello, I am trying to convert a sql query into a BAQ. In this SQL query there are calculating invoice totals by week, but the weeks are not the standard 7 day week, its based on 8 days. So, starting at 1, if the day of the month is 8, 16, 24, or the last day of the month the week count should go up by one.
I was think I could use a CTE to achieve this, but I’m having some issues, here is what I tried.
I created a CTE query with InvcHed and my calculated field. From InvcHed I just brought in Invoice Number, Invoice Date, and my calculated field. My calculated field is “WeekNum” and it starts with a static value of 1.
Then I created a UnionAll query. Brought in InvcHed (alias InvcHed1) and my CTE query, linking them by Invoice number. Put the Invoice Number, Invoice Date, and a new calculate field. My calculated field is referencing my calculated field from the CTE then a + 1.
Create a TopLevel query and bring in the CTE and show all the fields and my week number never increments. It just says 1 on every row. Figured I should get this before trying the week calculation with it.
Clearly I’m missing something and any advice would be appreciated. Thanks!