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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
RuZaGo
Regular Visitor

dax formula help

Hello,

 

I have a table with the following data: Account, year, month, euros. Each record has the total of money that has entered or exited an account in that month. Something like that:

 

Account   Year    Month  Euros 

5200        2017         1       800

5200        2017         2     -100

5200        2017         3       500

5200        2017         4   - 1800

524          2017         1       100

524          2017         2      -300

524         2017         3      -200

524         2017         4       500


I want to add a column that also tells me the balance. That is ... the balance to January 2017, is the sum of all fields "euros" from the beginning to the registration that has month 1, year 2017, for a certain account. In February, it is the same sum adding the record that has month 2, year 2017. Something like this:

 

Account   Year    Month  Euros   Balance

5200       2017         1       800         800

5200       2017         2     -100          700 

5200       2017         3       500       1200

5200       2017         4   - 1800       -600 

524         2017         1       100         100

524         2017         2      -300       -200

524         2017         3      -200       -400

524         2017         4       500       100



I've tried solving it in several ways with CALCULATE, but I do not give the solution. Any ideas?

 

1 ACCEPTED SOLUTION

Hi @RuZaGo,

 

Please create a calculated column below: 

 

Balance = CALCULATE(SUM(Table1[Euros]),FILTER('Table1','Table1'[Account]=EARLIER(Table1[Account]) && 'Table1'[Month]<=EARLIER(Table1[Month])))

 

p1.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
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

4 REPLIES 4
Greg_Deckler
Super User
Super User

Maybe something like:

 

Balance = CALCULATE( SUM([Euros]), FILTER(Table, [Month] <= EARLIER([Month]))

You could also play around with the Running Total quick measure. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
RuZaGo
Regular Visitor

Hello,

 

I have a table with the following data: Account, year, month, euros. Each record has the total of money that has entered or exited an account in that month. Something like that:

 

Account   Year    Month  Euros 

5200        2017         1       800

5200        2017         2     -100

5200        2017         3       500

5200        2017         4   - 1800

524          2017         1       100

524          2017         2      -300

524         2017         3      -200

524         2017         4       500


I want to add a column that also tells me the balance. That is ... the balance to January 2017, is the sum of all fields "euros" from the beginning to the registration that has month 1, year 2017, for a certain account. In February, it is the same sum adding the record that has month 2, year 2017. Something like this:

 

Account   Year    Month  Euros   Balance

5200       2017         1       800         800

5200       2017         2     -100          700 

5200       2017         3       500       1200

5200       2017         4   - 1800       -600 

524         2017         1       100         100

524         2017         2      -300       -200

524         2017         3      -200       -400

524         2017         4       500       100



I've tried solving it in several ways with CALCULATE, but I do not find the solution. Any ideas?

 

Hi @RuZaGo,

 

Please create a calculated column below: 

 

Balance = CALCULATE(SUM(Table1[Euros]),FILTER('Table1','Table1'[Account]=EARLIER(Table1[Account]) && 'Table1'[Month]<=EARLIER(Table1[Month])))

 

p1.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

It works! Thank you very much

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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