Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

View all the Fabric Data Days sessions on demand. View schedule

Reply
ElkanaTheGreat
Frequent Visitor

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.

 

PolicyNumberPremiumPaidpolicystartpolicyendPremiumPerDayVehicle Type
1100001 January 201831 December 20182.7Car
2400007 March 201806 March 201911Van

 

I have created a daily calendar table using the DAX function CALENDAR and summed the PremiumPerDay for active policies which looks like this. 

DatePremium
01/01/2018 00:002.7
02/01/2018 00:002.7
03/01/2018 00:002.7
04/01/2018 00:002.7
05/01/2018 00:002.7
06/01/2018 00:002.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.

1 ACCEPTED SOLUTION

@ElkanaTheGreat

 

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 ( PolStart0 )EOMONTH ( PolEnd0 )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]
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

10 REPLIES 10
LivioLanzo
Solution Sage
Solution Sage

Hi  @ElkanaTheGreat !

 

please find the file below, let mke know if this is what you want

https://1drv.ms/u/s!AiiWkkwHZChHjyhnUmBt4cEYlZJf

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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

@ElkanaTheGreat

 

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?

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

This wouldn't help much as I have more factors than just vehicle type so table will get exponentially bigger with each added factor.

 

Perhaps it is just better to earn by month only so that the table won't get too big.

 

Is it possible to use GENERATE to get the months between start and end date rather than like you did with CALENDAR which gets all the days.

@ElkanaTheGreat

 

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 ( PolStart0 )EOMONTH ( PolEnd0 )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]
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Hi,

 

It looks like my statments in the previous messahe were incorrect.  Without creating one row for each date, there can be a solution provided you would not want to see day wise premium collected.  You may download the PBI file from here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

On the x axis of the graph, will you always want to show Months only?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Would want to be able to show everything but I guess I'd hardly use days so months would be a good second best

Hi,

 

Though i have not tried an alternative solution diligently, my guess is that the DAX formula for that would be very intensive (if we do not break out the table into individual date rows).  This is because we would have to create an inactive relationship between policyend date and the Date column of the Calendae Table.  Furthermore, by breaking out the Table into individual date wise rows, we can use other Date/Time intelligence functions.

 

I tried to create one row per month instead of one row per date but then the problem is that if we assign the first date of the month to the row, then we are assuming that the plicy start date is the first date (which in many cases will not be true).

 

Sorry but cannot help much here.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

 

You may download my PBI file from here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors