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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Tamerlane
Helper I
Helper I

Calculated column for balance per customer in timeline

Hi everyone,

 

I have a table with customer balances in a timeline. Now I want to show how the balance has developed over time, per customer, in a calculated column.

 

So for example, I have this table called CustomerTransactions:

Customer   Transdate    Balance    Desired column

112             1-1-2020     500           500

112             1-5-2020     900           1400

112             4-5-2020     -200          1200

113             1-1-2020     400            400

113             2-5-2020     -900           -500

113             8-5-2020     300            -200

 

Anyone know how to get this 'Desire column'? Thanks!

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

Hi, @Tamerlane 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

Table:

d1.png

 

You may create a calculated column or a measure as below.

Calculated column:

Result Column = 
var _customer = [Customer]
var _transdate = [Transdate]
return
CALCULATE(
    SUM('Table'[Balance]),
    FILTER(
        ALL('Table'),
        'Table'[Customer]=_customer&&
        'Table'[Transdate]<=_transdate
    )
)

 

Measure:

Result Measure = 
var tab = 
ADDCOLUMNS(
    'Table',
    "Result",
    var _customer = [Customer]
    var _transdate = [Transdate]
    return
    CALCULATE(
        SUM('Table'[Balance]),
        FILTER(
            ALL('Table'),
            'Table'[Customer]=_customer&&
            'Table'[Transdate]<=_transdate
        )
    )
)
return
SUMX(
    tab,
    [Result]
) 

 

Result:

d2.png

 

Best Regards

Allan

 

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
v-alq-msft
Community Support
Community Support

Hi, @Tamerlane 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

Table:

d1.png

 

You may create a calculated column or a measure as below.

Calculated column:

Result Column = 
var _customer = [Customer]
var _transdate = [Transdate]
return
CALCULATE(
    SUM('Table'[Balance]),
    FILTER(
        ALL('Table'),
        'Table'[Customer]=_customer&&
        'Table'[Transdate]<=_transdate
    )
)

 

Measure:

Result Measure = 
var tab = 
ADDCOLUMNS(
    'Table',
    "Result",
    var _customer = [Customer]
    var _transdate = [Transdate]
    return
    CALCULATE(
        SUM('Table'[Balance]),
        FILTER(
            ALL('Table'),
            'Table'[Customer]=_customer&&
            'Table'[Transdate]<=_transdate
        )
    )
)
return
SUMX(
    tab,
    [Result]
) 

 

Result:

d2.png

 

Best Regards

Allan

 

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

 

amitchandak
Super User
Super User

@Tamerlane 

as new column

Desired column= SUMX(filter(all(Table),Table[Transdate] <=earlier(Table[Transdate]) && Table[Customer] =earlier(Table[Customer])),Sales[Balance])

 

As new measure

Desired Measure = CALCULATE(SUM(Sales[Balance]),filter(all(Table),Table[Transdate] <=max(Table[Transdate]) && Table[Customer] =max(Table[Customer])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
parry2k
Super User
Super User

@Tamerlane check this post.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.

Top Solution Authors