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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sirisadashiva
Employee
Employee

Cumulative Monthly From Yearly Cost

Hello,

I am new to DAX and Power BI. I have been struggling with this for a couple of weeks. I would be grateful for any help on the cost report I'm currently working on.

 

I have a Table with columns:

Id   StartDate      EndDate      AnnualCost 

1    02/10/2010   02/10/2011   120,000

2    04/3/2010     04/03/2011   100,000

3    03/14/2011   03/14/2012   200,000

 

I also have a separate Calendar Table.

 

I need to calculate cumulative monthly totals from this.

 

Initially I added Month dates extracted from start and end date fields and calculated annual cost per month like so:

 

Id   StartDate      EndDate      AnnualCost  MonthEndDate AnnualCostPerMonth

1    02/10/2010   02/10/2011   120,000      03/09/2010          10,000

1    02/10/2010   02/10/2011   120,000      04/09/2010          10,000

......

2    04/3/2010     04/03/2011   100,000      03/02/2011          8333.33

.....

3    03/14/2011   03/14/2012   200,000      04/13/2011          1666.666

....... till EndDate

 

I then connected the Table [MonthEndDate] to Calendar table and calculated the cumulative with the measure: 

 

Cumulative  = CALCULATE(SUM(Table[AnnualCostPerMonth]),
FILTER(ALLSELECTED(Table),
Table[MonthEndDate] <= MAX('Calendar'[Date])))
 
This did give me the right answer, however it is expanding the Table to thousands of rows when I add the MonthEndDate column to the Table. How do I avoid this? 
 
 
(Essentially, the Id fields should not be repeated, so I need to avoid splitting the start-end date into monthly dates) 

 

 

2 REPLIES 2

Thank you, I looked at those, it causes the Id fields to be repeated which I'm trying to avoid. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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