Forum Discussion
Dynamically link earned premiums table to policy table
In insurance it is useful to see the premium that is being earned over a given period. For example if an insurance policy is sold for $1000 a year it will earn $2.74 every day.
I want to be able to show a line graph of earned premiums over time with the ability to add different policy factors to the legend.
This as an example of the data I have.
| PolicyNumber | PremiumPaid | policystart | policyend | PremiumPerDay | Vehicle Type |
| 1 | 1000 | 01 January 2018 | 31 December 2018 | 2.7 | Car |
| 2 | 4000 | 07 March 2018 | 06 March 2019 | 11 | Van |
I have created a daily calendar table using the DAX function CALENDAR and summed the PremiumPerDay for active policies which looks like this.
| Date | Premium |
| 01/01/2018 00:00 | 2.7 |
| 02/01/2018 00:00 | 2.7 |
| 03/01/2018 00:00 | 2.7 |
| 04/01/2018 00:00 | 2.7 |
| 05/01/2018 00:00 | 2.7 |
| 06/01/2018 00:00 | 2.7 |
It is now simple to create a line graph showing earned premiums over time using just the date table. However there is no way for me to drag the vehicle type field into the legend of this graph.
Is there a way for me to structure/link my data in Power BI in a different way so that I can add factors like the vehicle type into the legend of this graph quickly and dynamically?
To see this sample data more clearly see here.
https://www.dropbox.com/s/zewoxg0gcl4mdl6/PremiumEarning.pbix?dl=0
Thanks so much.
Try this new file which is grouped by month:
https://1drv.ms/u/s!AiiWkkwHZChHjylF131vK9FcAbY9
The new grouped table can be generated like this:
PremiumsMonthly =
SELECTCOLUMNS (
ADDCOLUMNS (
GENERATE (
Table1,
VAR PolStart = Table1[policystart]
VAR PolEnd = Table1[policyend]
RETURN
GENERATESERIES (
1,
DATEDIFF ( EOMONTH ( PolStart, 0 ), EOMONTH ( PolEnd, 0 ), MONTH ) + 1
)
),
"Days", 1
+ MIN ( Table1[policyend], EOMONTH ( Table1[policystart], [Value] - 1 ) )
- MAX ( EOMONTH ( Table1[policystart], [Value] - 2 ) + 1, Table1[policystart] ),
"Month", EOMONTH ( Table1[policystart], [Value] - 1 )
),
"PolicyNumber", Table1[PolicyNumber],
"Premium", Table1[PremiumPerDay] * [Days],
"VehicleType", Table1[Vehicle Type],
"MonthDate", [Month],
"Days", [Days]
)
10 Replies
- Ashish_MathurSuper User
- LivioLanzoSolution Sage
- ElkanaTheGreatFrequent Visitor
Hi thanks for this it is an interesting solution but will be extremely memory intensive for lots of policies. Is there a way of doing this without adding extra rows for each day?
Thanks
- LivioLanzoSolution Sage
the table I am creating could be further aggregated by vehicle type so that the number of rows is drastically reduced. Could you upload a dataset including a bit more policies / vehicles types?