Forum Discussion

Peter2023's avatar
Peter2023
Icon for Helper I rankHelper I
1 year ago
Solved

Calculate Actual booking

Hello, Please help me resolve the following issue. I want to calculate the monthly actual booking using the formula: Actual Booking the current month = Actual Booking of the previous month + Bookin...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Peter2023 

    First, change the type of "Monthnumber"




    Then try the following measure:

    Measure = 
    VAR _month = SELECTEDVALUE('Date Lib'[Monthnumber])
    VAR _current_booking = [Booking]
    VAR _current_cancel = [Cancel]
    VAR _current_retails = [Retails]
    VAR _previous_booking = SUMX(FILTER(ALL('Date Lib'),'Date Lib'[Monthnumber] <= _month-1),[Booking])
    VAR _previous_cancel = SUMX(FILTER(ALL('Date Lib'),'Date Lib'[Monthnumber] <= _month-1),[Cancel])
    VAR _previous_retails = SUMX(FILTER(ALL('Date Lib'),'Date Lib'[Monthnumber] <= _month-1),[Retails])
    
    RETURN
    _current_booking + _previous_booking -_current_cancel - _current_retails -_previous_cancel - _previous_retails

     

    Result:

     

     

     

     

    Best Regards,

    Jayleny

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Peter2023 

    First, use the following dax to get the week number:

    weeknum = WEEKNUM('Date lib'[Date])

     

    Then try the following Measure:

    Actual booking = 
    VAR _month = SELECTEDVALUE('Date lib'[Monthnumber])
    VAR _week = SELECTEDVALUE('Date lib'[weeknum])
    VAR _current_booking = [Booking]
    VAR _current_cancel = [Cancel]
    VAR _current_retails = [Retails]
    VAR _previous_booking_month = SUMX(FILTER(ALL('Date lib'),'Date lib'[Monthnumber] <= _month-1),[Booking])
    VAR _previous_cancel_month = SUMX(FILTER(ALL('Date lib'),'Date lib'[Monthnumber] <= _month-1),[Cancel])
    VAR _previous_retails_month = SUMX(FILTER(ALL('Date lib'),'Date lib'[Monthnumber] <= _month-1),[Retails])
    VAR _previous_booking_week = SUMX(FILTER(ALL('Date lib'),'Date lib'[weeknum] <= _week-1),[Booking])
    VAR _previous_cancel_week = SUMX(FILTER(ALL('Date lib'),'Date lib'[weeknum] <= _week-1),[Cancel])
    VAR _previous_retails_week = SUMX(FILTER(ALL('Date lib'),'Date lib'[weeknum] <= _week-1),[Retails])
    
    RETURN 
    IF(ISINSCOPE('Date lib'[weeknum]),_current_booking + _previous_booking_week -_current_cancel - _current_retails -_previous_cancel_week - _previous_retails_week,_current_booking + _previous_booking_month -_current_cancel - _current_retails -_previous_cancel_month - _previous_retails_month)

     

    Result:

     

     

     

    Best Regards,

    Jayleny

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.