powerbi - Forecasting issue in Power BI - Stack Overflow

I am trying to forecast current month performance based on how far we are in the month.Goal is to esta

I am trying to forecast current month performance based on how far we are in the month. Goal is to establish how many cancellations will come in current month by inception. My DAX seems to be working fine when it comes to forecasting totals for items bought and cancelled in current month, but it doesn't want to forecast this month cancellation on product bought in previous months - it brings actuals up to date instead.

Any suggestions?

Here is my DAX:

Cancellations by inception = 
VAR CurrentDate = [RefreshDate] -1
VAR CurrentMonth = MONTH(CurrentDate)
VAR CurrentYear = YEAR(CurrentDate)
VAR DaysElapsed = DAY(CurrentDate)
VAR TotalDaysInMonth = DAY(EOMONTH(CurrentDate, 0))
VAR RemainingDays = TotalDaysInMonth - DaysElapsed
 
-- Actual cancellations per month using the USERELATIONSHIP
VAR Actuals =
    CALCULATE(sum
    (fact_canc[Totals]),
        USERELATIONSHIP(dimDate[Date], fact_canc[SaleDate]),
        YEAR(dimDate[Date]) = YEAR(MAX(dimDate[Date])),
        MONTH(dimDate[Date]) = MONTH(MAX(dimDate[Date]))
    )
 
-- Current month cancellations up to today
VAR CurrentMonthActuals =
    CALCULATE(
        sum(fact_canc[Totals]),
        USERELATIONSHIP(dimDate[Date], fact_canc[SaleDate]),
        YEAR(dimDate[Date]) = CurrentYear,
        MONTH(dimDate[Date]) = CurrentMonth,
        fact_canc[SaleDate] <= CurrentDate
    )
-- Forecasted total for the current month
VAR DailyRunRate = DIVIDE(CurrentMonthActuals, DaysElapsed, 0)
VAR ForecastedCurrentMonth = CurrentMonthActuals + (DailyRunRate * RemainingDays)
 
RETURN
     IF(
        YEAR(MAX(dimDate[Date])) = CurrentYear && MONTH(MAX(dimDate[Date])) = CurrentMonth,
        ForecastedCurrentMonth,
         Actuals
         )+0

Tried to to change this part :

VAR CurrentMonthActuals =
    CALCULATE(
        sum(fact_canc[Totals]),
        USERELATIONSHIP(dimDate[Date], fact_canc[SaleDate]),
        YEAR(dimDate[Date]) = CurrentYear,
        MONTH(dimDate[Date]) = CurrentMonth,
        fact_canc[SaleDate] <= CurrentDate
    ) 

as this is when I believe problem occurs

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744616867a4584104.html

相关推荐

  • powerbi - Forecasting issue in Power BI - Stack Overflow

    I am trying to forecast current month performance based on how far we are in the month.Goal is to esta

    2天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信