Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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
Solved! Go to Solution.
@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]
)
Proud to be a 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]
)
Proud to be a Super User! |
|
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |