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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
DA1981
Frequent Visitor

Sum calculation filtered on multiple dates

Hello all!

 

I am struggling to do a sum where the calculation is referencing 2 dates when trying to calculate the sum of insurance premium on a (historical) daily basis.

 

The ‘active premium’ on any given day (valuation date) will sum the premium of all policies that are ‘active’. Active is defined if the start date of the policy is on or before the valuation date and the end date is after the valuation date. Simply put, the policy is mid-term on that valuation date. Note that the valuation date is just a date, i.e. snapshot in time not a date range such as a month or quarter.

 

This is a boiled down data of what sample data looks like. If we used a valuation date of 01 March for example, we would sum the premium for policy 2 & 3 and the active premium for that date would be 250+50=300.

 

Table.PNG

 

I have joined the above table to a date table on start date and  end date. I dont know if this is causing a problem?

 

To calculate for today I would do the following calculation:

 

Active Premium = CALCULATE(
                              SUM(Book[Premium]),
                              Book[Start Date]<=TODAY(),
                              Book[End Date]>TODAY()     )

 

 

I need this active premium calculated at every (valuation) date in the past 2 years, not just today, where I can then graphically represent it in a way that looks aesthetically pleasing, i.e. whether I want to look at snapshots at month end, quarter end, yearend or even a line graph with daily data points. I would like to use the dates in the date table as the historic valuation dates. 

 

Quite new to Power BI and very new to DAX. Thanks in advance for any help!

1 ACCEPTED SOLUTION
1 REPLY 1

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.