Primary key change by filter

Hello Looker Team

I have one table called “end of day balances” which contain balances of each day for each account. so every account will have one record in the table at any particular day and table have records since 2010. There is no unique id of each records so i concat accountid and date column as a compound primary key

now i have to join this table with “collection cases” table. Collection cases table have cases open for the accounts which are not paying the balance. So i will do the join on accountid (from balances table) = account__c( from collection table) and collection_table_date=‘today’

If you notice in my join clause, i am joining on non primary key (accountid) but if i choose filter date “today” then logically my accountid is the primary key, but i haven’t defined it in my model anywhere. How looker will know that accountid is the primary key of balances table when date is “1 day”

Can you please advise me if i am doing the right way?

Thank you in advance

Hi Ramanpreet!

If I understand correctly, I don’t think this is a problem.

If a table’s PK is a compound, like (account_id,date) and you join like JOIN balances ON balances.account_id = other.account_id and = today, then that is still a many-to-one join because you have equality constraints on all of your primary key columns.

Perhaps I haven’t understood your situation exactly though, so feel free to let me know

Hello Fabio

Thank you for your reply .

Actually my question was, in my table : I defined pk = Concat of accountid and date

But in my model I am doing join on accountId which is not the primary key I defined in first place. Kindly advise if this will cause any issue

Thank you