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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
alya1
Helper V
Helper V

How to continuously subtract/add column values from a single number

Hello,

 

I created 2 tables (via New Table -> DAX) with the columns below:

Add

Year  Month  Add Number  
2020Jan9
2020Feb7
2020Mar3
...  
2025Dec6

Subtract

Year  Month  Subtract Number  
2020Jan4
2020Feb5
2020Mar8
...  
2025Dec6

I have another table that I got distinct count of customers from Dec 31st 2019. Let's say it is 100 for simplicity sake. 

How can I calculate a new column for rolling monthly customer count like below:

Year  Month  Customer Count  
2020Jan105 (100+9-4)
2020Feb107 (105+7-5)
2020Mar102 (107+3-8)
...  
2025Dec### (### from previous month+6-6)


Thank you!

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @alya1 

 

In Power BI there is no easy way to refer to a "previous row", this is generally done by adding all numbers to date for both numbers to be added as well as for numbers to be subtracted and add those to the beginning balance.

 

In my example pbix below, I accomplish this by using separate measures or a single measure like this:

 

 

Balance = 
VAR _BegBal = MAX( 'BegBal'[Balance] )   // you will need to use your calculation
VAR _Curr = MAX( 'Date'[Date] )
VAR _Added =
    CALCULATE(
        SUM( 'Add'[Number] ),
        'Date'[Date] <= _Curr
    )
VAR _Subtracted =
    CALCULATE(
        SUM( 'Subtract'[Number] ),
        'Date'[Date] <= _Curr
    )
VAR _Result = _BegBal + _Added - _Subtracted
RETURN
    _Result

 

 

 

How to continuously subtract or add column values from a single value.pbix

 

Let me know if you have any questions.

 

(I'm pretty sure this could be done using  WINDOW  as well if you want.)

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

1 REPLY 1
gmsamborn
Super User
Super User

Hi @alya1 

 

In Power BI there is no easy way to refer to a "previous row", this is generally done by adding all numbers to date for both numbers to be added as well as for numbers to be subtracted and add those to the beginning balance.

 

In my example pbix below, I accomplish this by using separate measures or a single measure like this:

 

 

Balance = 
VAR _BegBal = MAX( 'BegBal'[Balance] )   // you will need to use your calculation
VAR _Curr = MAX( 'Date'[Date] )
VAR _Added =
    CALCULATE(
        SUM( 'Add'[Number] ),
        'Date'[Date] <= _Curr
    )
VAR _Subtracted =
    CALCULATE(
        SUM( 'Subtract'[Number] ),
        'Date'[Date] <= _Curr
    )
VAR _Result = _BegBal + _Added - _Subtracted
RETURN
    _Result

 

 

 

How to continuously subtract or add column values from a single value.pbix

 

Let me know if you have any questions.

 

(I'm pretty sure this could be done using  WINDOW  as well if you want.)

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.