I have a set of data below.
| AdviserName | PolicyNumber | Product | Status | Duration |
|-------------|--------------|---------|--------|----------|
| Andy | LIF123 | ANZ | New | 2 |
| Andy | X224 | AXA | Lapsed | 3 |
| George | KL1122 | TAL | New | 0 |
| George | OLK43 | AXA | Lapsed | 5 |
| Ben | LIF98 | ANZ | New | 0 |
| Ben | KL343 | TAL | Lapsed | 1 |
I want to get the set of data where the status = 'Lapsed' duration between 1 to 3. However I still want to show correspond status = 'New' for each adviser. Below is the expected result that I want to see.
| AdviserName | PolicyNumber | Product | Status | Duration |
|-------------|--------------|---------|--------|----------|
| Andy | LIF123 | ANZ | New | 2 |
| Andy | X224 | AXA | Lapsed | 3 |
| Ben | LIF98 | ANZ | New | 0 |
| Ben | KL343 | TAL | Lapsed | 1 |
I created 2 parameters :
MinYear
with the value set to 1MaxYear
with the value set to 3
I created 2 calculated fields :
MinInvYear
which isiif([Duration]>=[Min Year] and [Status] = 'Lapsed', 1, 0)
MaxInvYear
which isiif([Duration]<=[Max Year] and [Status] = 'Lapsed', 1, 0)
Last step, I put both calculated fields into the filters and tick the filter = 1 only. Unfortunately what I got is the table below. I need to show the status 'New' as well for Andy and Ben.
| AdviserName | PolicyNumber | Product | Status | Duration |
|-------------|--------------|---------|--------|----------|
| Andy | X224 | AXA | Lapsed | 3 |
| Ben | KL343 | TAL | Lapsed | 1 |
I tried to modify the calculated field using Level of Detail :
MinInvYear
which is {include [Status] = 'New Business' : iif([Duration]>=[Min Year] and [Status] = 'Lapsed', 1, 0)}
and I got error message 'Result of a level of detail expression must be aggregate.'
What am I missing?
FYI, I'm using Tableau 10.
Thanks all for your help.