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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
gomezc73
Helper V
Helper V

Help to calculate Average in a accumulated measure

Hi Experts,

 

I need help with the following problem, any idea on how to solve it would be appreciated.

 

I have a table that has an amount per day, so I made a measure to generate an accumulated amount by day .

Something like this:

gomezc73_1-1732280824728.png

 

Now, The users needs see an Average by month, considering only the data filtered.

 

Let me explain, if the user select show the data only for TUESDAY, he need see an AVERAGE like this:

gomezc73_2-1732280986642.png

 

If the User select all days (Sun-Sat), I need sum all accumulated amount divided by the num of days of the month.

 

This is the data for JAN & FEB 2023 with the accumulated amount in TUESDAY.

YearQTMonthWeek#Week DayDate Beg. Balance  Daily Amount  Accumulated
Amount 
2023Q1Jan1Tue01/03/2023  (3,633,363,058.57)      (171,002,732.78)  (3,804,365,791.35)
2023Q1Jan2Tue01/10/2023  (3,633,363,058.57)      (206,220,918.69)  (3,839,583,977.26)
2023Q1Jan3Tue01/17/2023  (3,633,363,058.57)      (266,672,453.96)  (3,900,035,512.53)
2023Q1Jan4Tue01/24/2023  (3,633,363,058.57)      (357,264,773.29)  (3,990,627,831.86)
2023Q1Jan5Tue01/31/2023  (3,633,363,058.57)      (220,729,172.89)  (3,854,092,231.46)
2023Q1Feb6Tue02/07/2023  (3,633,363,058.57)      (485,377,556.93)  (4,118,740,615.50)
2023Q1Feb7Tue02/14/2023  (3,633,363,058.57)      (550,096,607.34)  (4,183,459,665.91)
2023Q1Feb8Tue02/21/2023  (3,633,363,058.57)      (634,502,523.92)  (4,267,865,582.49)
2023Q1Feb9Tue02/28/2023  (3,633,363,058.57)      (523,876,044.55)  (4,157,239,103.12)

 

Thanks in advance

 

Regards

 

 

 

 

 

9 REPLIES 9
v-mengmli-msft
Community Support
Community Support

Hi @gomezc73 ,

 

Do you want to calculate average monthly Accumulated Amount? What's the denominator? Assuming it is the days of the month are the rows of data per month, you can do this. 

Average Accumulated Amount = 
VAR current_month =MAX('Table'[Month])
VAR selected_week =ALLSELECTED('Table'[Week Day])
VAR total= CALCULATE(SUM('Table'[Accumulated Amount]),ALL('Table'),'Table'[Month]=current_month&&'Table'[Week Day] in selected_week)
VAR countR = CALCULATE(COUNTROWS('Table'),ALL('Table'),'Table'[Month]=current_month&&'Table'[Week Day] in selected_week)
RETURN
total/countR

vmengmlimsft_0-1732514862547.png

 

 

 

Best regards,

Mengmeng Li

 

Hi,

 

 Thank you for your response,

 

 In this instruction I get an error, due the 'Accumulate amount; is in a 'measure variable' and The command SUM only acept a 'COLUMN VARIABLE'. How i can change it?

VAR total= CALCULATE(SUM('Table'[Accumulated Amount]),

 

Hi @gomezc73 ,

 

Is 'Accumulate amount' a measure? If so, you can try this.

VAR total= CALCULATE(SUMX('Table',[Accumulate amount]),ALL('Table'),'Table'[Month]=current_month&&'Table'[Week Day] in selected_week)

If the above DAX does not solve the problem, please provide more information about 'Accumulate amount'. For example, how it was created and what else it is used for.

 

 

Best regards,

Mengmeng Li

Hi, Thank you for time. I tried with your response but it is generating wrong Averages.

 

I have two tables: 

A Calendar table (Called Calendario)

A daily file (Called F0911), in this file i have a monthly amount

 

Then I created this measure to Accumulate the amounts:

gomezc73_0-1732628732291.png

 

This is the Measure that i use for Accumulate the amounts:

Acum_Detail =
VAR _fechaSel =SELECTEDVALUE(F0911[GL_DATE])
VAR _Jan01  = DATE(SELECTEDVALUE(Calendario[Year]),01,01)
 
VAR _DailyAcum=
CALCULATE(
SUM(F0911[AMOUNT]),
FILTER(ALL(Calendario[Date]), Calendario[Date]>=_Jan01 && Calendario[Date] <= _fechaSel))

RETURN
_DailyAcum
saud968
Super User
Super User

Try this

Create a Measure for Accumulated Amount:

Create a measure to calculate the accumulated amount by day.
Accumulated Amount =
CALCULATE(
SUM('Table'[Daily Amount]),
FILTER(
ALL('Table'),
'Table'[Date] <= MAX('Table'[Date])
)
)
Create a Measure for Monthly Average:

Create a measure to calculate the average accumulated amount by month, considering the filtered data.
Monthly Average Accumulated Amount =
VAR FilteredDays = COUNTROWS(VALUES('Table'[Date]))
VAR TotalAccumulated = SUM('Table'[Accumulated Amount])
RETURN
IF(
FilteredDays > 0,
TotalAccumulated / FilteredDays,
BLANK()
)
Create a Visual:

Add a visual (e.g., a table or a line chart) to display the monthly average accumulated amount.
Use the Month column on the axis and the Monthly Average Accumulated Amount measure as the value.
Apply Filters:

Add slicers or filters to allow users to select specific days (e.g., only Tuesdays).
The measure will automatically update based on the selected filters.

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

divyed
Super User
Super User

Hello @gomezc73 ,

 

Please share data in excel format removing sensitive data of any .

 

Cheers

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/

Thank you for your earle response,

 

this is the daily data for Jan/Feb 2023.

YearQTMonthWeek#Week DayDate Beg. Balance  Daily Amount  Accumulated
Amount 
2023Q1Jan1Sun01/01/2023  (3,633,363,058.57)      (200,793,352.34)  (3,834,156,410.91)
2023Q1Jan1Mon01/02/2023  (3,633,363,058.57)      (160,984,809.71)  (3,794,347,868.28)
2023Q1Jan1Tue01/03/2023  (3,633,363,058.57)      (171,002,732.78)  (3,804,365,791.35)
2023Q1Jan1Wed01/04/2023  (3,633,363,058.57)      (187,864,203.54)  (3,821,227,262.11)
2023Q1Jan1Thu01/05/2023  (3,633,363,058.57)      (203,681,447.59)  (3,837,044,506.16)
2023Q1Jan1Fri01/06/2023  (3,633,363,058.57)      (183,632,474.30)  (3,816,995,532.87)
2023Q1Jan1Sat01/07/2023  (3,633,363,058.57)      (151,498,500.22)  (3,784,861,558.79)
2023Q1Jan2Sun01/08/2023  (3,633,363,058.57)      (154,679,706.85)  (3,788,042,765.42)
2023Q1Jan2Mon01/09/2023  (3,633,363,058.57)      (174,369,516.83)  (3,807,732,575.40)
2023Q1Jan2Tue01/10/2023  (3,633,363,058.57)      (206,220,918.69)  (3,839,583,977.26)
2023Q1Jan2Wed01/11/2023  (3,633,363,058.57)      (236,211,164.03)  (3,869,574,222.60)
2023Q1Jan2Thu01/12/2023  (3,633,363,058.57)      (258,153,570.51)  (3,891,516,629.08)
2023Q1Jan2Fri01/13/2023  (3,633,363,058.57)      (251,865,102.92)  (3,885,228,161.49)
2023Q1Jan2Sat01/14/2023  (3,633,363,058.57)      (233,377,305.04)  (3,866,740,363.61)
2023Q1Jan3Sun01/15/2023  (3,633,363,058.57)      (208,237,287.73)  (3,841,600,346.30)
2023Q1Jan3Mon01/16/2023  (3,633,363,058.57)      (232,621,139.40)  (3,865,984,197.97)
2023Q1Jan3Tue01/17/2023  (3,633,363,058.57)      (266,672,453.96)  (3,900,035,512.53)
2023Q1Jan3Wed01/18/2023  (3,633,363,058.57)      (299,258,224.42)  (3,932,621,282.99)
2023Q1Jan3Thu01/19/2023  (3,633,363,058.57)      (335,272,651.29)  (3,968,635,709.86)
2023Q1Jan3Fri01/20/2023  (3,633,363,058.57)      (349,768,788.13)  (3,983,131,846.70)
2023Q1Jan3Sat01/21/2023  (3,633,363,058.57)      (343,437,136.23)  (3,976,800,194.80)
2023Q1Jan4Sun01/22/2023  (3,633,363,058.57)      (327,954,547.86)  (3,961,317,606.43)
2023Q1Jan4Mon01/23/2023  (3,633,363,058.57)      (341,233,603.36)  (3,974,596,661.93)
2023Q1Jan4Tue01/24/2023  (3,633,363,058.57)      (357,264,773.29)  (3,990,627,831.86)
2023Q1Jan4Wed01/25/2023  (3,633,363,058.57)      (387,481,162.91)  (4,020,844,221.48)
2023Q1Jan4Thu01/26/2023  (3,633,363,058.57)      (401,421,287.46)  (4,034,784,346.03)
2023Q1Jan4Fri01/27/2023  (3,633,363,058.57)      (409,091,519.76)  (4,042,454,578.33)
2023Q1Jan4Sat01/28/2023  (3,633,363,058.57)      (397,470,111.77)  (4,030,833,170.34)
2023Q1Jan5Sun01/29/2023  (3,633,363,058.57)      (372,610,512.51)  (4,005,973,571.08)
2023Q1Jan5Mon01/30/2023  (3,633,363,058.57)      (383,348,709.47)  (4,016,711,768.04)
2023Q1Jan5Tue01/31/2023  (3,633,363,058.57)      (220,729,172.89)  (3,854,092,231.46)
2023Q1Feb5Wed02/01/2023  (3,633,363,058.57)      (437,990,270.92)  (4,071,353,329.49)
2023Q1Feb5Thu02/02/2023  (3,633,363,058.57)      (467,710,764.13)  (4,101,073,822.70)
2023Q1Feb5Fri02/03/2023  (3,633,363,058.57)      (474,584,309.43)  (4,107,947,368.00)
2023Q1Feb5Sat02/04/2023  (3,633,363,058.57)      (462,276,357.37)  (4,095,639,415.94)
2023Q1Feb6Sun02/05/2023  (3,633,363,058.57)      (447,085,664.68)  (4,080,448,723.25)
2023Q1Feb6Mon02/06/2023  (3,633,363,058.57)      (463,843,973.76)  (4,097,207,032.33)
2023Q1Feb6Tue02/07/2023  (3,633,363,058.57)      (485,377,556.93)  (4,118,740,615.50)
2023Q1Feb6Wed02/08/2023  (3,633,363,058.57)      (514,364,746.89)  (4,147,727,805.46)
2023Q1Feb6Thu02/09/2023  (3,633,363,058.57)      (528,997,690.50)  (4,162,360,749.07)
2023Q1Feb6Fri02/10/2023  (3,633,363,058.57)      (556,233,576.50)  (4,189,596,635.07)
2023Q1Feb6Sat02/11/2023  (3,633,363,058.57)      (541,522,262.93)  (4,174,885,321.50)
2023Q1Feb7Sun02/12/2023  (3,633,363,058.57)      (508,599,533.49)  (4,141,962,592.06)
2023Q1Feb7Mon02/13/2023  (3,633,363,058.57)      (521,117,133.42)  (4,154,480,191.99)
2023Q1Feb7Tue02/14/2023  (3,633,363,058.57)      (550,096,607.34)  (4,183,459,665.91)
2023Q1Feb7Wed02/15/2023  (3,633,363,058.57)      (577,518,344.42)  (4,210,881,402.99)
2023Q1Feb7Thu02/16/2023  (3,633,363,058.57)      (602,029,788.49)  (4,235,392,847.06)
2023Q1Feb7Fri02/17/2023  (3,633,363,058.57)      (624,044,082.24)  (4,257,407,140.81)
2023Q1Feb7Sat02/18/2023  (3,633,363,058.57)      (610,344,120.33)  (4,243,707,178.90)
2023Q1Feb8Sun02/19/2023  (3,633,363,058.57)      (582,228,014.87)  (4,215,591,073.44)
2023Q1Feb8Mon02/20/2023  (3,633,363,058.57)      (606,782,402.39)  (4,240,145,460.96)
2023Q1Feb8Tue02/21/2023  (3,633,363,058.57)      (634,502,523.92)  (4,267,865,582.49)
2023Q1Feb8Wed02/22/2023  (3,633,363,058.57)      (668,756,145.05)  (4,302,119,203.62)
2023Q1Feb8Thu02/23/2023  (3,633,363,058.57)      (693,499,600.23)  (4,326,862,658.80)
2023Q1Feb8Fri02/24/2023  (3,633,363,058.57)      (707,633,820.40)  (4,340,996,878.97)
2023Q1Feb8Sat02/25/2023  (3,633,363,058.57)      (694,673,124.90)  (4,328,036,183.47)
2023Q1Feb9Sun02/26/2023  (3,633,363,058.57)      (664,142,827.66)  (4,297,505,886.23)
2023Q1Feb9Mon02/27/2023  (3,633,363,058.57)      (682,582,459.17)  (4,315,945,517.74)
2023Q1Feb9Tue02/28/2023  (3,633,363,058.57)      (523,876,044.55)  (4,157,239,103.12)

Hello @gomezc73 ,

 

Try below dax pls, replace table names and values accordingly.

 

Average_Total_Balance_Per_Month =
AVERAGEX(
SUMMARIZE(
'YourTable',
'YourTable'[Year],
'YourTable'[Month],
"Monthly_Total_Balance",
SUM('YourTable'[Begining_Balance] + 'YourTable'[Daily_Balance])
),
[Monthly_Total_Balance]
)

 

Did I answer your query ? Mark this as solution if this helps. Kudos are appreciated.

 

Cheers

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/

Hi,

  The 'Beggining Balance' and 'Monthly Balance'  are MEASURES VARIABLES, not COLUMNS field, so when I use the SUM function it tells me it "The SUM function only accepts a column reference as an argument".

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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