Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Help needed in getting rolling numbers for dates

Hi Team, I'm seeking some help in achieving the below scenario in PowerBI which we can easily get using Excel formula.  I want to get the total no. of applications for each date ("Tme" column...
  • v-angzheng-msft's avatar
    5 years ago

    Hi, Anonymous 

    According to your description, what I understand is that only the first row of the application count column has a value, and the values of the remaining rows are calculated by the formula: A-B+C.

    If it is what I think it is, please see my solution.

    Sample data:

    If you want to get the same results as in Excel, we can create the following metasure:

     

    Measure =
    CALCULATE(
        SUM('Table'[Applications count]),
        FILTER(ALL('Table'),[Time]<=MAX('Table'[Time]))
    )
    -
    CALCULATE(
        SUM('Table'[Deprictae]),
        FILTER(ALL('Table'),[Time]<MAX('Table'[Time]))
    )
    +
    CALCULATE(
        SUM('Table'[New Add]),
        FILTER(ALL('Table'),[Time]<MAX('Table'[Time]))
    )

     

    Or we can achieve the same result by creating calculated columns.

    What I did is to calculate the first value of Applications count column with the row-by-row accumulation of the remaining two columns

    I created 3 columns to be used as auxiliary calculations, the DAX is as follows:

     

    Column = CALCULATE(MAX('Table'[Applications count]),FILTER('Table',[Time]<=EARLIER('Table'[Time])))
    Column 2 = CALCULATE(SUM('Table'[Deprictae]),FILTER('Table',[Time]<EARLIER('Table'[Time])))
    Column 3 = CALCULATE(SUM('Table'[New Add]),FILTER('Table',[Time]<EARLIER('Table'[Time])))

     

    So the expression of the final result is very simple:

     

    Result = [Column]-[Column 2]+[Column 3]

     

    Result:

    Please check the sample pbix file's link down below

     

    Is this the result you want? Hope this is useful to you

    Please feel free to let me know If you have further questions

     

    Best Regards,
    Community Support Team _ Zeon Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.