Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
sonm10
Helper I
Helper I

Cumulative calcualtion on the same column

Hello All,

 

I have a table with various item and their value for dates. I have calculated the change of their value as return. Now I need to create a column that refers to its previous value of the same column. My data is as follows:

 

DateTypeValueReturnColumn
1/1/2020A1 100
1/2/2020A21200
1/3/2020A30.5101
1/4/2020A40.333333134.6667
1/5/2020A50.25102
1/1/2020B7 100
1/2/2020B80.142857103
1/3/2020B90.125115.875
1/4/2020B100.111111104
1/5/2020B110.1114.4
     

 

I need to calculate the new column whose formula is:

if(return = 0), then 100

else previous value * (1+ return)

 

It is quite staright forward in excel. We can directly do, E4 = E3*(1+D4)

 

When i create a similar formula in DAX, i am getting a circular loop error. Any helps is appreciated.

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @sonm10 ,

 

Please check if this is what you want:

Column 2 =
VAR CurrentDate = [Date]
VAR t =
    ADDCOLUMNS ( 'Table', "Return_1", [Return] + 1 )
RETURN
    PRODUCTX (
        FILTER ( t, [Type] = EARLIER ( [Type] ) && [Date] <= CurrentDate ),
        [Return_1]
    ) * 100

column2.PNG

But I have some confusion. Is the data marked above written wrong?

 

 

Best Regards,

Icey

 

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

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @sonm10 ,

 

Please check if this is what you want:

Column 2 =
VAR CurrentDate = [Date]
VAR t =
    ADDCOLUMNS ( 'Table', "Return_1", [Return] + 1 )
RETURN
    PRODUCTX (
        FILTER ( t, [Type] = EARLIER ( [Type] ) && [Date] <= CurrentDate ),
        [Return_1]
    ) * 100

column2.PNG

But I have some confusion. Is the data marked above written wrong?

 

 

Best Regards,

Icey

 

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

Thanks a lot @Icey . Exactly what i wanted. I had made some mistakes in the sample data and yet you provided exactly what i wanted.

amitchandak
Super User
Super User

@sonm10 , try a new column

 

if(coalesce([Return],0) =0,100 , [value] * (1+ [return]))

 

if(([Return]+0) =0,100 , [value] * (1+ [return]))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.