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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
madhushree
Frequent Visitor

Cumulative sum of a measure per date

Need help to calculate cumulative sum of a measure.

Below is the table what i need. Till X(MTD) i am able to do.

DateUsage minutesX(MTD)Y
1-Oct8500.590.590278
2-Oct12560.730.660764
3-Oct9000.700.672454
4-Oct12000.730.686892
5-Oct14400.780.706347

Description:

X(MTD) is a measure that give cumulated minutes used, calculated as below

for 1st oct : usage 850 and 1st day so X(MTD) is 850/(1*1440)=0.59

for 2nd oct : usage is 850+1256 and 2nd day so X(MTD) is 2106/(2*1440)=0.73

for 3rd oct : usage is 850+1256+900 and 3rd day so X(MTD) is 3006/(3*1440)=0.70

But for Y i need the sum X(MTD) measure and divided by day i.e.,

for 1st oct : X(MTD) 0.59 and 1st day so Y should be 0.59/1=0.59

for 2nd oct : X(MTD) 0.73 and 2nd day so Y should be 0.73/2=0.66

for 3rd oct : X(MTD) 0.70 and 3rd day so Y should be 0.70/3=0.67

I have already written formula for X(MTD),How can i write formula for y. As X(MTD) is measure i am not able to use sum([(MTD)]). 

1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@madhushree

 

For your X(MTD), we can directly create a measure like below:

 

X = TOTALMTD(SUM(Usage[Usage minutes]),Usage[Date]) / (CALCULATE(SUM(Usage[Usage minutes]),LASTDATE(ALLSELECTED(Usage[Date]))) * TOTALMTD(COUNTROWS(),Usage[Date]) )

Then you want to calculate the rolling average based on above measure. However, this is a TOTALMTD() over another TOTALMTD(), to make calculation on measure value, we have to summarize it into a column. So I suggest you create a calculated table like: 

 

Table 2 = SUMMARIZE(Usage,Usage[Date],"x value",[X])

Build the relationship to source table on Date column. Then use TOTALMTD on that "x value" column.

 

Y = TOTALMTD(SUM('Table 2'[x value]),'Table 2'[Date])/TOTALMTD(COUNTROWS(),'Table 2'[Date])

123.PNG

 

Regards,

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi @madhushree,

 

Try this

 

=[X(MTD)]/DAY(MAX(CALENDAR[Date]))

 

In your visual, i have assumed that the Date field is coming from the Calrndar Table.  Also, there is a relationshion from the Date column of your base data table to the Date column of your Calendar table.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-sihou-msft
Microsoft Employee
Microsoft Employee

@madhushree

 

For your X(MTD), we can directly create a measure like below:

 

X = TOTALMTD(SUM(Usage[Usage minutes]),Usage[Date]) / (CALCULATE(SUM(Usage[Usage minutes]),LASTDATE(ALLSELECTED(Usage[Date]))) * TOTALMTD(COUNTROWS(),Usage[Date]) )

Then you want to calculate the rolling average based on above measure. However, this is a TOTALMTD() over another TOTALMTD(), to make calculation on measure value, we have to summarize it into a column. So I suggest you create a calculated table like: 

 

Table 2 = SUMMARIZE(Usage,Usage[Date],"x value",[X])

Build the relationship to source table on Date column. Then use TOTALMTD on that "x value" column.

 

Y = TOTALMTD(SUM('Table 2'[x value]),'Table 2'[Date])/TOTALMTD(COUNTROWS(),'Table 2'[Date])

123.PNG

 

Regards,

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.