Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
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.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
86 | |
81 | |
70 | |
49 |
User | Count |
---|---|
143 | |
124 | |
107 | |
60 | |
55 |