Forum Discussion
Forecast Distribution
- 2 years ago
if you dont want to create all these columns
use this :
combined = var ds = ADDCOLUMNS( ADDCOLUMNS( ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[date], 'Table'[planned] ), "forecasted", var planned = 'Table'[planned] var earned = 25 -- dynamic base on your calculated measure i assume. var forecasted = SWITCH( TRUE(), 'Table'[date]< TODAY() , 0 , 'Table'[planned] >= earned , planned, 'Table'[planned] < earned , earned ) return forecasted, "remaining", SUMX( FILTER( 'Table', 'Table'[date]>= TODAY() ), 'Table'[planned] ) ), "cumul_foreacsted" , SUMX( FILTER( 'Table', 'Table'[date] <=EARLIER('Table'[date]) ), 'Table'[forecasted] ) ), "forecasted corrected", var next_nb = SELECTCOLUMNS( OFFSET(-1, SUMMARIZE( 'Table', 'Table'[date], 'Table'[remaining], 'Table'[cumul forecasted] ), ORDERBY('Table'[date], asc ) ), "next_period" , 'Table'[cumul forecasted] ) var res = SWITCH( TRUE(), 'Table'[cumul forecasted] <= 'Table'[remaining] , 'Table'[cumul forecasted] - next_nb, abs('Table'[remaining] - 'Table'[cumul forecasted]) < 'Table'[earned] , 'Table'[remaining] - next_nb ) return res ) return MAXX( FILTER( ds, 'Table'[date] = EARLIER('Table'[date]) ), [forecasted corrected] ) - Anonymous2 years ago
Hi AllanBerces
Your solution is great, Daniel29195 . It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.
Calculated column:
Column = VAR _RemainingHrs = 187 -- Replace [Measure1] with your actual measure for Remaining hrs VAR _AvgEarnedHrs = 25 -- Replace [Measure2] with your actual measure for Average earned hrs VAR _maxdate = [Date] RETURN IF([Daily Plan_rev] <> 0, IF([Daily Plan_rev] < _AvgEarnedHrs , _AvgEarnedHrs, [Daily Plan_rev]), 0)Measure:
Forecast Distribution = VAR _RemainingHrs = 187 -- Replace [Measure1] with your actual measure for Remaining hrs VAR _AvgEarnedHrs = 25 -- Replace [Measure2] with your actual measure for Average earned hrs VAR _maxdate = MAX([Date]) VAR _sum = CALCULATE(SUM('Table'[Column]), FILTER(ALL('Table'), [Date] <= _maxdate)) VAR _result = IF(MAX([Daily Plan_rev]) <> 0, IF(MAX([Daily Plan_rev]) < _AvgEarnedHrs , _AvgEarnedHrs, MAX([Daily Plan_rev])), 0) VAR _result1 = IF(_RemainingHrs - _sum >= _result, _result, _RemainingHrs - _sum) RETURN IF(_result1 < 0, BLANK(), _result1)Result:
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
output : forecast_corrected is the column to achieve.
steps :
you need some column helpers ( although you can achieve it all in one column, but creating multiple columns for better undestanding ) .
columns to calculate :
planned -- given
earned -- given
forecasted =
var planned = 'Table'[planned]
var earned = 25 -- dynamic base on your calculated measure i assume.
var remaining =
SUMX(
FILTER(
'Table',
'Table'[date]>= TODAY()
),
'Table'[planned]
)
var forecasted =
SWITCH(
TRUE(),
'Table'[date]< TODAY() , 0 ,
'Table'[planned] >= earned , planned,
'Table'[planned] < earned , earned
)
return forecasted
remaining -->
remaining =
SUMX(
FILTER(
'Table',
'Table'[date]>= TODAY()
),
'Table'[planned]
)
cumul_forecasted -->
cumul forecasted =
var cumul_foreacsted =
SUMX(
FILTER(
'Table',
'Table'[date] <=EARLIER('Table'[date])
),
'Table'[forecasted]
)
return cumul_foreacsted
forecasted correct -->
forecasted corrected =
var next_nb =
SELECTCOLUMNS(
OFFSET(-1,
SUMMARIZE(
'Table',
'Table'[date],
'Table'[remaining],
'Table'[cumul forecasted]
),
ORDERBY('Table'[date], asc )
),
"next_period" , 'Table'[cumul forecasted]
)
var res =
SWITCH(
TRUE(),
'Table'[cumul forecasted] <= 'Table'[remaining] , 'Table'[cumul forecasted] - next_nb,
abs('Table'[remaining] - 'Table'[cumul forecasted]) < 'Table'[earned] , 'Table'[remaining] - next_nb
)
return res
let me know if this helps.
If this hepled you solving your problem, make sure to give it a thumbs up and mark it as a solution so others can find it quickly .
forecasted modified :
forecasted =
var planned = 'Table'[planned]
var earned = 25 -- dynamic base on your calculated measure i assume.
var forecasted =
SWITCH(
TRUE(),
'Table'[date]< TODAY() , 0 ,
'Table'[planned] >= earned , planned,
'Table'[planned] < earned , earned
)
return forecasted
- AllanBerces2 years agoPost Prodigy
Hi Daniel29195 Anonymous, just want to ask regarding the solution above, instead of one category let say 4 or 5 category on the same table which part on the above solution i will change.
Thank you