Forum Discussion

Paulo84's avatar
Paulo84
Frequent Visitor
3 years ago
Solved

Forecast based on what-if parameter commencing after actuals

Hi Team, 

I have an issue which probably has an incredibly simple solution, but which I can't seem to find! 


I have a model which has two what if paramteres - "monthly defections" and "monthly joins" - the difference between the two (joins - defections) is a measure called [Projected Monthly Mbr gain].


I have a table with a Year / Month date column (from date dim table), a measure called [Total Open Accounts] which is an actual count of open accounts as of the end of that particular Year / Month. It will not provide a count for the current month onwards. 

 

I want to write a measure [Projected Open Accounts] to provide a "forecast" of sorts for the periods after the actuals (total open accounts). In this case, from 2023-Apr onward. 

The calculation for [Projected Open Accounts] is simple, it begins with the latest [Total Open Accounts] number - In this case 2023-Mar - 70,775.

 

It then adds the amount of the [Projected Monthly Mbr Gain] on to this number. For example, if the [Projected Monthly Mbr Gain] was 300 then [Projected Open Accounts] for 2023-Apr would be 71,075. 2023-May would be 71,375, 2023-Jun would be 71,675 and so on ... 

I can help but think there is a simple solution for all this - any assistance is greatly appreciated!

  • Hello Paulo84

     

    please see see this possibility:

     

    Project open accounts = 
    var _periode = SELECTEDVALUE('Table'[Year_Month_ID])+1 - (YEAR(TODAY())*100+MONTH(TODAY()))
    
    var _last_month = 
        CALCULATE(
            MAX('Table'[Year_Month_ID]),
            FILTER(ALL('Table'),'Table'[Open Accounts]<>BLANK())
        )
    
    var _value = 
        CALCULATE(
            sum('Table'[Open Accounts]),
            FILTER(ALL('Table'),'Table'[Year_Month_ID]=_last_month)
        )
    
    return 
    if( 
        [Total Open Accounts] = BLANK(), 
        _periode*[Project Monthly Member Gain] + _value,
       BLANK()
    )

     

    also i share an example so can compare with yours in the following LINK:

     

    max by category.pbix

     

     

    Best regards

    Bruno Costa | Solution Supplier

     

    Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 👍

    Take a look at the blog: PBI Portugal 

  • Thanks for reply onurbmiguel_ ! 

    Unfortunately, your solution didn't quite work with my existing measures - However, I tweaked it slightly to produce the outcome I was looking for:

    Forecast open accounts = 
    
    VAR _date = SELECTEDVALUE('DATE'[End of month])
    
    VAR LatestDate =
        CALCULATE(
            MAX('DATE'[end of month]),
            FILTER(ALL('DATE'), NOT(ISBLANK([Total Open Accounts])))
        )
    
    VAR MonthNumDifference = 
    
        CALCULATE(
            DATEDIFF(LatestDate, _date, MONTH)
        )
    
    VAR LatestCount =
        CALCULATE(
            [Total Open Accounts],
            FILTER(ALL('DATE'), 'DATE'[end of month] = LatestDate)
        )
    
    VAR NetMbrGain = [Projected Monthly Mbr Gain]
    
    VAR MonthlyDefections = 'Parameter - Monthly Defections'[Parameter Value]
    
    RETURN
    
    IF(
        _date <= LatestDate, 
        BLANK (), 
        (NetMbrGain * MonthNumDifference) + LatestCount 
    )

     
    Many thanks for your assistance!

3 Replies

  • onurbmiguel_'s avatar
    onurbmiguel_
    Icon for Power Participant rankPower Participant

    Hello Paulo84

     

    please see see this possibility:

     

    Project open accounts = 
    var _periode = SELECTEDVALUE('Table'[Year_Month_ID])+1 - (YEAR(TODAY())*100+MONTH(TODAY()))
    
    var _last_month = 
        CALCULATE(
            MAX('Table'[Year_Month_ID]),
            FILTER(ALL('Table'),'Table'[Open Accounts]<>BLANK())
        )
    
    var _value = 
        CALCULATE(
            sum('Table'[Open Accounts]),
            FILTER(ALL('Table'),'Table'[Year_Month_ID]=_last_month)
        )
    
    return 
    if( 
        [Total Open Accounts] = BLANK(), 
        _periode*[Project Monthly Member Gain] + _value,
       BLANK()
    )

     

    also i share an example so can compare with yours in the following LINK:

     

    max by category.pbix

     

     

    Best regards

    Bruno Costa | Solution Supplier

     

    Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 👍

    Take a look at the blog: PBI Portugal 

  • Paulo84's avatar
    Paulo84
    Frequent Visitor

    Thanks for reply onurbmiguel_ ! 

    Unfortunately, your solution didn't quite work with my existing measures - However, I tweaked it slightly to produce the outcome I was looking for:

    Forecast open accounts = 
    
    VAR _date = SELECTEDVALUE('DATE'[End of month])
    
    VAR LatestDate =
        CALCULATE(
            MAX('DATE'[end of month]),
            FILTER(ALL('DATE'), NOT(ISBLANK([Total Open Accounts])))
        )
    
    VAR MonthNumDifference = 
    
        CALCULATE(
            DATEDIFF(LatestDate, _date, MONTH)
        )
    
    VAR LatestCount =
        CALCULATE(
            [Total Open Accounts],
            FILTER(ALL('DATE'), 'DATE'[end of month] = LatestDate)
        )
    
    VAR NetMbrGain = [Projected Monthly Mbr Gain]
    
    VAR MonthlyDefections = 'Parameter - Monthly Defections'[Parameter Value]
    
    RETURN
    
    IF(
        _date <= LatestDate, 
        BLANK (), 
        (NetMbrGain * MonthNumDifference) + LatestCount 
    )

     
    Many thanks for your assistance!

    • onurbmiguel_'s avatar
      onurbmiguel_
      Icon for Power Participant rankPower Participant

      Hello, 

       

      You didn't share the model, so I tried to come up with some dummy values ​​to help you out.
      You kind of replicated my logic, can you please accept my solution?

       

      Best regards

      Bruno Costa | Solution Supplier

       

      Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 👍

      Take a look at the blog: PBI Portugal