Forum Discussion
Many to one filtering while aggregating at the same time
Hi all,
I have 2 tables, A and B. A looks as follow:
| id_unique | var 1 | var 2 |
| 1 | 1 | 0 |
| 2 | 1 | 0 |
| 3 | 0 | 1 |
| .... | .... | .... |
And B looks as follow (not all "id_unique" of table A is in "id" and "id" is also not unique):
| id | product | have bought? |
| 1 | A | 1 |
| 3 | B | 0 |
| 3 | C | 1 |
| ..... | ... | ... |
I enabled the many-to-one relationship between the two tables using the column id_unique and id respectively.
I'd like to get the % of products purchased per product. One way that I've tried is to use the column "product" in table B as axis and average of "have bought" as values. However, this won't enable me to use table B to filter A. Another method I tried was to remove all the rows with 0s in "have bought?" and it works to filter, but the problem is that now I can get the count but not the %. I tried to use a measure from Table A to count number of rows in A and then divide count in b with that measure, but it would only take into account all the rows that has common id between the two tables. Would love to get your feedback on this. Thank you so much!
1 Reply
- Ashish_MathurSuper User
Hi,
Your question is not clear. What are the Var 1 and Var 2 columns in Table 1? What end result are you expecting? Please show that clearly.