Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

How to get Rolling total for forecast.

Hi Team,

 Can you please advise me how to calculate Runway (Rolling Total) in powerbi using DAX like below.

The below highlighed column is achived using Excel spreadsheet with Row No.  I am struggling to get it in powerbi DAX.

Runway by CF for Nov = Total of current forecast - forecast of Nov

Runways by CF for Dec onwards = Runway by CF - forecast of Dec  a and so on....

 

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Thanks Irwan. It works as column measure. For empty value,I can replace it with 0 for last month..right.?

    Thanks for this solution buddy 🙂

  • Its pretty easy. Just change the measure to this

     

     

    RunAwayByCf = 
    VAR _py =
        CALCULATE (
            IF ( SUM ( Data[CurrentForecast] ) = 0, 0, SUM ( Data[CurrentForecast] ) ),
            ALLEXCEPT ( Data, Data[FI Name]),
            MIN(Data[Index] ) <= Data[Index] -1
        )
    RETURN
        INT ( _py )

     


    which gives the following o/p. I have sorted it on FI Name so that its easy to validate the results.

     



     

     

  • Can you check if the DAX you are using is the same as one I posted last time ?



    Now I am using the new code and I see no issues.


  • Anonymous's avatar
    Anonymous
    2 years ago

    HI SachinNandanwar   its working with earlier code itself. 

     

    Do u have any idea how to get Runway by Burn rate

    Runway by Burn Rate calculated in excel 
    Nov =SUM(C:C)-C2
    Dec onwards = F2-E2,F3-E3,F4-E4
     
    Expected result should show like this .
    For CCC =--
    IndexMonthSum of current costRunway by CCBurn RateRunway by Burn Rate
    1Nov2182282819358253132.22819358
    2Dec15940026599582182282566225.833
    3Jan19064524693131906452347997.833
    4Feb18313622861771831362157352.833
    5Mar19396720922101939671974216.833
    6Apr22977618624342297761780249.833
    7May28392315785112839231550473.833
    8Jun25777113207402577711266550.833
    9Jul2805601040180253132.21008779.833
    10Aug336528703652253132.2755647.6667
    11Sep337392366260253132.2502515.5
    12Oct3662600253132.2249383.3333

36 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    You can try formula like below to create measure:

    Runway by CF = 
    VAR CurrentMonth = MAX('Table'[Index])
    VAR TotalForecast = CALCULATE(SUM('Table'[Current Forecast]), ALL('Table'))
    VAR RollingTotal = 
        CALCULATE(
            SUM('Table'[Current Forecast]),
            FILTER(
                ALL('Table'),
                'Table'[Index] <= CurrentMonth
            )
        )
    RETURN
        TotalForecast - RollingTotal + SUM('Table'[Current Forecast])
    

    Best Regards,
    Adamk Kong

     

    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
      Not applicable

      Hi AdamK,

       This solution doesnt serve the purpose your column Runway by CF is not coming to zero in end.

       

      It should be like below

       

  • SachinNandanwar's avatar
    SachinNandanwar
    Icon for Impactful Individual rankImpactful Individual

    Incase if you want the calculation through a measure

    RunAwayByCf =
    VAR _py =
        CALCULATE (
            IF ( SUM ( Data[CurrentForecast] ) = 0, 0, SUM ( Data[CurrentForecast] ) ),
            ALLEXCEPT ( Data, Data[Index] ),
            MAX ( Data[Index] ) < ( Data[Index] )
        )
    RETURN
        INT ( _py )

     

     



     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi SachinNandanwar  and Irwan  Thansk for your solution as well. It works as a measure. Now,this code works for me when I have only 3 columns like Index,Month and Current Cost  for FI name "CCC" i.e single excel file having only CCC data.

       

       

       

      However, when I use actual file which has same columns categorized into different FI Name..Thsi code doesnt work..Its giving wrong values in Runway. Can youn please suggest how to use this code for different values of FI for same month and monthly runway. This mentioned runway has wrong values now.

       

      IndexMonthFI NameSum of Current CostRunway 
      1NovCCC$218,2285346154
      1NovBBB$3,5365346154
      1NovAAA$210,9355346154
      2DecCCC$159,4005073944
      2DecBBB$3,0975073944
      2DecAAA$109,7135073944
      3JanCCC$190,6454700108
      3JanBBB$15,4644700108
      3JanAAA$167,7274700108
      4FebCCC$183,1364356710
      4FebBBB$13,5414356710
      4FebAAA$146,7214356710
      5MarCCC$193,9673973667
      5MarBBB$19,1763973667
      5MarAAA$169,9003973667
      6AprCCC$229,7763530976
      6AprBBB$24,9843530976
      6AprAAA$187,9313530976
      7MayCCC$283,9233072933
      7MayBBB$12,8443072933
      7MayAAA$161,2763072933
      8JunCCC$257,7712580875
      8JunBBB$39,1472580875
      8JunAAA$195,1402580875
      9JulCCC$280,5602027297
      9JulBBB$57,2662027297
      9JulAAA$215,7522027297
      10AugCCC$336,5281374383
      10AugBBB$73,2551374383
      10AugAAA$243,1311374383
      11SepCCC$337,392716991
      11SepBBB$88,453716991
      11SepAAA$231,547716991
      12OctCCC$366,2600
      12OctBBB$94,0590
      12OctAAA$256,6720
      • SachinNandanwar's avatar
        SachinNandanwar
        Icon for Impactful Individual rankImpactful Individual

        Its pretty easy. Just change the measure to this

         

         

        RunAwayByCf = 
        VAR _py =
            CALCULATE (
                IF ( SUM ( Data[CurrentForecast] ) = 0, 0, SUM ( Data[CurrentForecast] ) ),
                ALLEXCEPT ( Data, Data[FI Name]),
                MIN(Data[Index] ) <= Data[Index] -1
            )
        RETURN
            INT ( _py )

         


        which gives the following o/p. I have sorted it on FI Name so that its easy to validate the results.

         



         

         

  • hello Anonymous 

     

    please check if this accomodate your need.

    Runway by CF =
    SUMX(
        FILTER(
            'Table',
            'Table'[Index]>EARLIER('Table'[Index])
        ),
        'Table'[Current Forecast]
    )

     

    Hope this will help you.

    Thank you.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Irwan  your result Runway by CF looks good to me but code is not working for me. Its giving me below error

       

       

      • Irwan's avatar
        Irwan
        Icon for Super User rankSuper User

        Anonymous 

         

        please use calculated column for that DAX (not measure).

         

        I got same error if I use that DAX in measure.

         

        Thank you