Linked rows question

Hi @stucork , apologies – I deleted the app that the clone in my previous message links to, because I am new here and didn’t know that deleting the app renders the clone link useless. So here’s a new clone I spun up. Same thing almost. Here’s the new clone link. Anvil | Login

Stuart and @meredydd I understand what the conditional statement you have given does. But as you can see, now nobody gets paid for the week :slight_smile:

Having worked with a few BI tools for the last several years - like Crystal Reports, Cognos, PowerBI, etc. I have a bit of experience in joining tables with each other. What I would expect when joining Table A (in this case ‘employee_master’) with Table B (in this case ‘salaries’), is that you would 1) first find / set the primary key of Table A, 2) then find / set the primary key of Table B and 3) join the two primary keys. Which way the arrow goes (from A to B or from B to A) determines what records are pulled up.

Why is it that in Anvil, there is no capability to do the above? Wouldn’t it make things a lot easier and kind of ‘standard’ practice? Also how do I solve my current problem? My clients where I work have all kinds of data distributed across dozens of tables (often across departments) and so I have to work across multiple tables to produce the reports I need to.

Thanks a lot for your help, Raj.

I guess anvil tables work a bit differently
here’s a related discussion Data Tables Join
There are others if you search for joins in the forum

Assuming you have a method somewhere that creates an employee row


@anvil.server.callable
def create_employee(employee_data, salary_data):
    id = gen_id()
    salary_row = app_tables.salaries.add_row(id=id, **salary_data)
    employee_row = app_tables.employees.add_row(id=id, salary=salary, **employee_data)
    return employee_row

But maybe you want to link them after they’ve been created


@anvil.server.callable
def link_by_id(id):
    employee_row = app_tables.employees.get(id=id)
    salary_row = app_tables.employees.get(id=id)
    employee_row["salary"] = salary_row

Hope that helps