Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
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!
Solved! Go to Solution.
Hi, @Tamerlane
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
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:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Tamerlane
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
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:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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])))
@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.
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
105 | |
69 | |
48 | |
47 | |
47 |