Looking up data into a custom table column

I have a table called 'listingsTable. It displays data from a query called getListingsTable. This table appears when I have double clicked on a customer row in a table called customerTable.

customerTable contains a field called CUSTOMER_ID
listingsTable contains a field called PRODUCT_ID

I have another query called getCustomerSales, with a field called SALES for combinations of CUSTOMER_ID and PRODUCT_ID

Is there a way (other than a JOIN via SQL), that would let me create a custom column in 'listingsTable' and map each row to a corresponding value in my getCustomerSales query?

...almost like a VLOOKUP where the {{customerTable.selectedRow.CUSTOMER_ID}} and {{listingsTable.currentRow.PRODUCT_ID}} matches a combination from the getCustomerSales query and displays the corresponding SALES value?

Hey @pod2,

This should be doable if you have both product_id and customer_id in the same row. You could create a custom column and in the mapped value use a find, e.g

{{ getCustomerSales.data.find ( x => x.customer_id === selectedSourceRow.customer_id && x.product_id === selectedSourceRow.product_id).sales }}

Assuming that:

  1. You're getCustomersales.data is formatted as an array,
  2. There are matches for all combinations (otherwise the find function will return an error, and you will have to account for that scenario in the function)

You should be getting the result you want.

I hope I understood this correctly and that this guides you towards a solution!

1 Like

Thanks for this appraoch @MiguelOrtiz

I'm going to try implementing this on Monday and will check back in with results!

1 Like

@MiguelOrtiz I was able to get this to work. Thanks again for the information!

1 Like