still not completely understanding how to do certain things in qlik.
- I have a table payments, which includes a payment status, and a reference_key
- I have a table payment references which has a reference_key and a reference_number.
payments has like 100 fields in it.
I just want to end up with a field in payments which has the reference number if the status is paid, and is blank if it's not - and I'm finding it oddly hard to do.
in sql it would just be
select
payments.*,
case when status='paid' then reference_number else '' end as reference_number
from
payments
inner join references on payments.reference_key = references.reference_key
but I'm having a real trouble doing this in qlik - what I tried to do is
left join (payments)
load reference_key, reference_number from [references.qvd](qvd)
where status = 'paid';
but that just gives me field "status" is not found - because of course the status isn't in references.
The only thing I can come up with that works is create rename payments to payments_temp, join to references - create another payments_temp_2 table with a calculated field with if() in that one - then create a new payments table from payments_temp_2 which drops the reference_number column and renames calculated_reference_number to reference_number - which ends up about ~350 lines of code.
clearly I'm doing something wrong - but how do I do it - it seems such a simple thing - and such a common problem?
Note - any number of lines of payments, with all difference statuses - could all be joining to the same reference number