cancel
Showing results for 
Search instead for 
Did you mean: 
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
amitchandak
Super User
Super User

1 REPLY 1
amitchandak
Super User
Super User

@DA1981 , refer if one the two blog can help you

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s || 50+Power Query List Functions : Learn Power Query List
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Dev Camp Session 26

Check it Out!

Mark your calendars and join us on Thursday, September 29 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors