I'm working on a measure to find the earliest date a customer has an insurance policy (excluding the current policy). The result is current year, by business, insured and policy. For each policy i need to find the earliest date (all time) that a customer had a policy. The current version is within the same business, but i am expecting that will change and will need to take business slicer selections into consideration so i want to keep as a measure and not a calculated column.
Some sample data:
[TABLE="width: 424"]
<TBODY>[TR]
[TD]business
[/TD]
[TD]insured
[/TD]
[TD]policy
[/TD]
[TD]premium
[/TD]
[TD]effdate
[/TD]
[TD]expdate
[/TD]
[/TR]
[TR]
[TD]A
[/TD]
[TD="align: right"]342
[/TD]
[TD]P1
[/TD]
[TD="align: right"]543
[/TD]
[TD="align: right"]1/1/2012
[/TD]
[TD="align: right"]1/1/2013
[/TD]
[/TR]
[TR]
[TD]A
[/TD]
[TD="align: right"]342
[/TD]
[TD]P2
[/TD]
[TD="align: right"]342
[/TD]
[TD="align: right"]3/1/2012
[/TD]
[TD="align: right"]3/1/2013
[/TD]
[/TR]
[TR]
[TD]A
[/TD]
[TD="align: right"]353
[/TD]
[TD]P3
[/TD]
[TD="align: right"]225
[/TD]
[TD="align: right"]2/1/2011
[/TD]
[TD="align: right"]2/2/2012
[/TD]
[/TR]
[TR]
[TD]B
[/TD]
[TD="align: right"]225
[/TD]
[TD]P4
[/TD]
[TD="align: right"]634
[/TD]
[TD="align: right"]1/1/2009
[/TD]
[TD="align: right"]1/1/2010
[/TD]
[/TR]
[TR]
[TD]B
[/TD]
[TD="align: right"]225
[/TD]
[TD]P5
[/TD]
[TD="align: right"]215
[/TD]
[TD="align: right"]2/1/2012
[/TD]
[TD="align: right"]2/1/2013
[/TD]
[/TR]
[TR]
[TD]B
[/TD]
[TD="align: right"]227
[/TD]
[TD]P6
[/TD]
[TD="align: right"]150
[/TD]
[TD="align: right"]2/1/2012
[/TD]
[TD="align: right"]2/1/2013
[/TD]
[/TR]
[TR]
[TD]C
[/TD]
[TD="align: right"]324
[/TD]
[TD]P7
[/TD]
[TD="align: right"]200
[/TD]
[TD="align: right"]6/1/2011
[/TD]
[TD="align: right"]6/1/2012
[/TD]
[/TR]
[TR]
[TD]C
[/TD]
[TD="align: right"]523
[/TD]
[TD]P8
[/TD]
[TD="align: right"]125
[/TD]
[TD="align: right"]3/1/2012
[/TD]
[TD="align: right"]3/1/2013
[/TD]
[/TR]
[TR]
[TD]C
[/TD]
[TD="align: right"]500
[/TD]
[TD]P9
[/TD]
[TD="align: right"]115
[/TD]
[TD="align: right"]3/1/2011
[/TD]
[TD="align: right"]3/1/2012
[/TD]
[/TR]
</TBODY>[/TABLE]
and the dax:
this actually works with the sample data, but with an actual data set of 300k rows after 5 minutes it does not finish. i suspect i'm selecting more data than i think i am.
I'll explain what i think the statement is doing and maybe some one can tell me where i'm wrong or if i'm right and there is a better performing way to write it.
get the min expdate
for the current insured
for the current business
all dates (for current insured and business)
all policies (for all dates for current insured and business)
and the count rows is how i am trying to exclude the current policy something I attempted to duplicate from Rob Collie's site Aged Debtors–Dynamic Banding in DAX « PowerPivotPro
here is a link to the actual workbook http://sdrv.ms/OwWR68
Thanks for any help.
Some sample data:
[TABLE="width: 424"]
<TBODY>[TR]
[TD]business
[/TD]
[TD]insured
[/TD]
[TD]policy
[/TD]
[TD]premium
[/TD]
[TD]effdate
[/TD]
[TD]expdate
[/TD]
[/TR]
[TR]
[TD]A
[/TD]
[TD="align: right"]342
[/TD]
[TD]P1
[/TD]
[TD="align: right"]543
[/TD]
[TD="align: right"]1/1/2012
[/TD]
[TD="align: right"]1/1/2013
[/TD]
[/TR]
[TR]
[TD]A
[/TD]
[TD="align: right"]342
[/TD]
[TD]P2
[/TD]
[TD="align: right"]342
[/TD]
[TD="align: right"]3/1/2012
[/TD]
[TD="align: right"]3/1/2013
[/TD]
[/TR]
[TR]
[TD]A
[/TD]
[TD="align: right"]353
[/TD]
[TD]P3
[/TD]
[TD="align: right"]225
[/TD]
[TD="align: right"]2/1/2011
[/TD]
[TD="align: right"]2/2/2012
[/TD]
[/TR]
[TR]
[TD]B
[/TD]
[TD="align: right"]225
[/TD]
[TD]P4
[/TD]
[TD="align: right"]634
[/TD]
[TD="align: right"]1/1/2009
[/TD]
[TD="align: right"]1/1/2010
[/TD]
[/TR]
[TR]
[TD]B
[/TD]
[TD="align: right"]225
[/TD]
[TD]P5
[/TD]
[TD="align: right"]215
[/TD]
[TD="align: right"]2/1/2012
[/TD]
[TD="align: right"]2/1/2013
[/TD]
[/TR]
[TR]
[TD]B
[/TD]
[TD="align: right"]227
[/TD]
[TD]P6
[/TD]
[TD="align: right"]150
[/TD]
[TD="align: right"]2/1/2012
[/TD]
[TD="align: right"]2/1/2013
[/TD]
[/TR]
[TR]
[TD]C
[/TD]
[TD="align: right"]324
[/TD]
[TD]P7
[/TD]
[TD="align: right"]200
[/TD]
[TD="align: right"]6/1/2011
[/TD]
[TD="align: right"]6/1/2012
[/TD]
[/TR]
[TR]
[TD]C
[/TD]
[TD="align: right"]523
[/TD]
[TD]P8
[/TD]
[TD="align: right"]125
[/TD]
[TD="align: right"]3/1/2012
[/TD]
[TD="align: right"]3/1/2013
[/TD]
[/TR]
[TR]
[TD]C
[/TD]
[TD="align: right"]500
[/TD]
[TD]P9
[/TD]
[TD="align: right"]115
[/TD]
[TD="align: right"]3/1/2011
[/TD]
[TD="align: right"]3/1/2012
[/TD]
[/TR]
</TBODY>[/TABLE]
and the dax:
Code:
[SIZE=1][SIZE=3]=calculate(min(Table1[expdate]),
[/SIZE]
[SIZE=3]VALUES(Table1[INSURED]),
VALUES(Table1[business]),
all(Table1[EffYear])[/SIZE]
[SIZE=3],all(Table1[policy]),
filter(all(Table1[policy]),
[/SIZE]
[SIZE=3]countrows(filter(table1,Table1[policy]<>EARLIER(Table1[policy])))>0))[/SIZE]
[/SIZE]
this actually works with the sample data, but with an actual data set of 300k rows after 5 minutes it does not finish. i suspect i'm selecting more data than i think i am.
I'll explain what i think the statement is doing and maybe some one can tell me where i'm wrong or if i'm right and there is a better performing way to write it.
get the min expdate
for the current insured
for the current business
all dates (for current insured and business)
all policies (for all dates for current insured and business)
and the count rows is how i am trying to exclude the current policy something I attempted to duplicate from Rob Collie's site Aged Debtors–Dynamic Banding in DAX « PowerPivotPro
here is a link to the actual workbook http://sdrv.ms/OwWR68
Thanks for any help.