Forum Discussion

Mekist's avatar
Mekist
Icon for Helper III rankHelper III
1 year ago

Collecting Cumulative Profit without Period

Hello

Below I am collecting the cumulative 4 periods backwards. If I put the period when I place it in the table, the data comes, there is no data when there is no period, when I put a share instead of a period, I will do the sum, but how can I do it without a period

 

 

Birikimli Kar = 
VAR Donem1 = MAX('Fiyatlar'[Dönem])

VAR Donem2 = 
    CALCULATE(
        MAX('Dönem'[Dönem]),
        FILTER(ALL('Dönem'),'Dönem'[Dönem] < Donem1))

VAR Donem3 = 
    CALCULATE(
        MAX('Dönem'[Dönem]),
        FILTER(ALL('Dönem'),'Dönem'[Dönem] < Donem2))

VAR Donem4 = 
    CALCULATE(
        MAX('Dönem'[Dönem]),
        FILTER(ALL('Dönem'),'Dönem'[Dönem] < Donem3))

VAR DonemKar1 =
    CALCULATE([Net Kar],'Dönem'[Dönem] = Donem1)

VAR DonemKar2 =
    CALCULATE([Net Kar],'Dönem'[Dönem] = Donem2)

VAR DonemKar3 =
    CALCULATE([Net Kar],'Dönem'[Dönem] = Donem3)

VAR DonemKar4 =
    CALCULATE([Net Kar],'Dönem'[Dönem] = Donem4)
RETURN
IF(
    NOT(ISBLANK(DonemKar1)) &&
    NOT(ISBLANK(DonemKar2)) &&
    NOT(ISBLANK(DonemKar3)) &&
    NOT(ISBLANK(DonemKar4)),
    DonemKar1 + DonemKar2 + DonemKar3 + DonemKar4,
    BLANK()
)

 

4 Replies

  • Mekist 

    If I understand correctly you want to perform 'Rolling sum' of last 4 periods. Please check this blog 

    https://www.sqlbi.com/articles/computing-running-totals-in-dax/

    Considering you want to perform over custom periods, it would be a little tricky. 

     

    If you need any further help then please share the pbix file with sample data and also do not forget to include expected outcome. 

     

    Need a Power BI Consultation? Hire me on Upwork

     

     

     

    Connect on LinkedIn

     

     

     








    Did I answer your question? Mark my post as a solution!
    If I helped you, click on the Thumbs Up to give Kudos.

    Proud to be a Super User!


    • Mekist's avatar
      Mekist
      Icon for Helper III rankHelper III

      Hello

      I did the test in the link, in total, no problem, I want to get to the table and collect the customer on the basis of period I am sending the sample study

       

      Example.pbx 

  • Hello

    I did the test in the link, in total, no problem, I want to get to the table and collect the customer on the basis of period I am sending the sample study

     

    Example.pbx