Forum Discussion
MT
8 years agoNew Member
Estimating monthly values from table using start date/end date
Hello everyone, I have data that looks like this: Identifier Start Date End Date Usage Value ABCF1234 1/01/2015 28/02/2015 387 AFDV1345 1/01/2015 12/01/2015 234 AFDV1345 ...
- 8 years ago
Hi MT
I think this might be getting close
Table = GROUPBY( FILTER( CROSSJOIN( -- Create and on the fly calendar table with a month column ADDCOLUMNS( CALENDARAUTO(), "Month",FORMAT([Date],"MMM-YY") ), -- Add a column to our base table that adds an average daily value ADDCOLUMNS( 'Table1', "Averate Usage Per Day", DIVIDE( 'Table1'[Usage Value], DATEDIFF( 'Table1'[Start Date], 'Table1'[End Date],DAY ) ) ) ), 'Table1'[Start Date] <= [Date] && 'Table1'[End Date] >= [Date] ), -- Perform the actual grouping here -- -- So Group by -- [Identifier], [Month], -- Now sum up the Average daily usage for the above groupings -- "Usage Value", SUMX( CURRENTGROUP(), [Averate Usage Per Day] ) )If I run this over your sample data I get the following result
Phil_Seamark
Microsoft Employee
8 years agoHi MT
I think this might be getting close
Table =
GROUPBY(
FILTER(
CROSSJOIN(
-- Create and on the fly calendar table with a month column
ADDCOLUMNS(
CALENDARAUTO(),
"Month",FORMAT([Date],"MMM-YY")
),
-- Add a column to our base table that adds an average daily value
ADDCOLUMNS(
'Table1',
"Averate Usage Per Day",
DIVIDE(
'Table1'[Usage Value],
DATEDIFF(
'Table1'[Start Date],
'Table1'[End Date],DAY
)
)
)
),
'Table1'[Start Date] <= [Date] &&
'Table1'[End Date] >= [Date]
),
-- Perform the actual grouping here --
-- So Group by --
[Identifier],
[Month],
-- Now sum up the Average daily usage for the above groupings --
"Usage Value", SUMX(
CURRENTGROUP(),
[Averate Usage Per Day]
)
)If I run this over your sample data I get the following result