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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CAZaidRazvi
New Member

Cumulative total +ve and -ve in separate column

Hi

 

I needed help with a problem that I'm facing, 

 

I have more than 100 schedules that are uniquely identifiable, Now each schedule has one column which has a first row that is negative  say USD (-10,000) and subsequet 60 rows that as positive say  USD 200,

Now if i cumulatively total this column it will become 0 on row 50 and they after become positive.

 

Now i Need to showcase each schedule separately to show which is +ve and which is still -ve at any given point of time. I need the total all Positive and Negative columns separately at any given date.

 

Sample.png

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @CAZaidRazvi 

You can refer to the following solution.

1.Add an index column in power query

vxinruzhumsft_0-1706062490974.png

2.Create the following calculated column.

Cumm =
VAR a =
    MIN ( 'Table'[Index] )
VAR b =
    LOOKUPVALUE ( 'Table'[Collection], 'Table'[Index], a )
RETURN
    b
        - SUMX (
            FILTER ( 'Table', [Index] <= EARLIER ( 'Table'[Index] ) && [Index] <> a ),
            [Collection]
        )
+VE = if([Cumm]>0,[Cumm])
-VE = IF([Cumm]<0,ABS([Cumm]))

Output

vxinruzhumsft_1-1706062693668.png

 

Best Regards!

Yolo Zhu

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

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @CAZaidRazvi 

You can refer to the following solution.

1.Add an index column in power query

vxinruzhumsft_0-1706062490974.png

2.Create the following calculated column.

Cumm =
VAR a =
    MIN ( 'Table'[Index] )
VAR b =
    LOOKUPVALUE ( 'Table'[Collection], 'Table'[Index], a )
RETURN
    b
        - SUMX (
            FILTER ( 'Table', [Index] <= EARLIER ( 'Table'[Index] ) && [Index] <> a ),
            [Collection]
        )
+VE = if([Cumm]>0,[Cumm])
-VE = IF([Cumm]<0,ABS([Cumm]))

Output

vxinruzhumsft_1-1706062693668.png

 

Best Regards!

Yolo Zhu

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

Thanks a lot, Much Appretiated

 

I had been picking my brains out for quite some time on solving this.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors