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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
dep
New Member

how to calculate the average in one month when some data start or finish in the previous/next month

dep_0-1740479623268.png

As you can see I change one key parameter in my process in different date and then I keep it for several days. Then I change for some reason. I would like the monthly average, knowing that sometime I start in the previous month ......

Can someone help me to build the proper way to calculate?

Thanks

 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@dep Create a Date Table:
DateTable =
CALENDAR (DATE(2024, 1, 1), DATE(2025, 12, 31))


Add Year and Month Columns to Date Table:

 

DateTable =
ADDCOLUMNS (
DateTable,
"Year", YEAR([Date]),
"Month", MONTH([Date])
)


Calculate Daily Values: Assuming you have a table named Data with columns StartDate, EndDate, and Value:
DailyValues =
ADDCOLUMNS (
GENERATE (
Data,
CALENDAR (Data[StartDate], Data[EndDate])
),
"DailyValue", Data[Value] / (DATEDIFF (Data[StartDate], Data[EndDate], DAY) + 1)
)


Distribute Values Across Days:
DistributedValues =
SUMMARIZE (
DailyValues,
[Date],
"TotalDailyValue", SUM (DailyValues[DailyValue])
)


Aggregate Monthly Values:
DAX
MonthlyValues =
SUMMARIZE (
DistributedValues,
YEAR([Date]), MONTH([Date]),
"TotalMonthlyValue", SUM (DistributedValues[TotalDailyValue])
)


Calculate Monthly Average:
DAX
MonthlyAverage =
ADDCOLUMNS (
MonthlyValues,
"DaysInMonth", DAY (EOMONTH (DATE (MonthlyValues[Year], MonthlyValues[Month], 1), 0)),
"MonthlyAverage", [TotalMonthlyValue] / [DaysInMonth]
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

1 REPLY 1
bhanu_gautam
Super User
Super User

@dep Create a Date Table:
DateTable =
CALENDAR (DATE(2024, 1, 1), DATE(2025, 12, 31))


Add Year and Month Columns to Date Table:

 

DateTable =
ADDCOLUMNS (
DateTable,
"Year", YEAR([Date]),
"Month", MONTH([Date])
)


Calculate Daily Values: Assuming you have a table named Data with columns StartDate, EndDate, and Value:
DailyValues =
ADDCOLUMNS (
GENERATE (
Data,
CALENDAR (Data[StartDate], Data[EndDate])
),
"DailyValue", Data[Value] / (DATEDIFF (Data[StartDate], Data[EndDate], DAY) + 1)
)


Distribute Values Across Days:
DistributedValues =
SUMMARIZE (
DailyValues,
[Date],
"TotalDailyValue", SUM (DailyValues[DailyValue])
)


Aggregate Monthly Values:
DAX
MonthlyValues =
SUMMARIZE (
DistributedValues,
YEAR([Date]), MONTH([Date]),
"TotalMonthlyValue", SUM (DistributedValues[TotalDailyValue])
)


Calculate Monthly Average:
DAX
MonthlyAverage =
ADDCOLUMNS (
MonthlyValues,
"DaysInMonth", DAY (EOMONTH (DATE (MonthlyValues[Year], MonthlyValues[Month], 1), 0)),
"MonthlyAverage", [TotalMonthlyValue] / [DaysInMonth]
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.