Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
Could you please help to get desired results from my table, the sample data is
Policy | policy trans no | policy from date | source |
321 | 1 | 01-01-2021 | branch |
321 | 2 | 01-03-2021 | online |
321 | 3 | 01-04-2021 | online |
321 | 1 | 01-01-2022 | online |
321 | 2 | 01-03-2022 | branch |
321 | 3 | 01-04-2022 | online |
desired results,
Last year source | |||
souce | count current year | branch | online |
online | 2 | 1 | 1 |
branch | 1 | 0 | 1 |
Please help
as below
temp:
load Policy,policytransno,date(date#(policyfromdate,'MM-DD-YYYY')) as policyfromdate,year(date#(policyfromdate,'MM-DD-YYYY')) as policyYear,source inline [
Policy,policytransno,policyfromdate,source
321,1,01-01-2021,branch
321,2,01-03-2021,online
321,3,01-04-2021,online
321,1,01-01-2022,online
321,2,01-03-2022,branch
321,3,01-04-2022,online
];
left join (temp)
load Policy,policytransno,(policyYear+1) as policyYear,source as LastYearSource
Resident temp;
exit Script;
Current Year
Count({<policyYear={"$(=Max(policyYear))"}>}Policy)
LastYear Branch
Count({<LastYearSource={'branch'}>}Policy)
LastYear Online
Count({<LastYearSource={'online'}>}Policy)