I added to my sales fact table a field that has the days difference between the last and last but one purchases by customer. On other hand I have a intervalmatch link table that gets the days difference as a argument and holds the lower and upper bound for different intervals name/title:
The tables seem to be linked just fine, except the days difference values are duplicates for every sale_id that has more than a product sold since I joined the days difference before by using sale_id.
It's not actually supposed to be a problem as I could Aggr and count distinct sale_ids by intervals and customers_id, and that's exactly what I'm trying to do. I can count the occurencies of a certain interval successfully with this expression:
But when I try to divide it by the total sales counting to find out the return rate % by days/interval, it only returns a value to the first interval, although the value is correct.
What am I missing?
This is the expression for intervals count / sales count: