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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Bring previous balance

Hi guys

I have many rows, with the account, account description, debits, credits, and the initial balance and the final balance, so my query for the initial balance is:

Starting balance =
VAR __Account = MAX([CTA_CONTABLE])
VAR __MinDate - MINX(FILTER('4 Balances','4 Balances'[CTA_CONTABLE] - __Account),[DATE])
RETURN
(MINX(FILTER('4 Balances','4 Balances'[CTA_CONTABLE] = __Account && [CLOSE] = __MinDate),[SALDO_INICIAL]))
With this I bring the initial balance of the last register (order by dates), because each raw is for a debit or a credit.
My problem is when I filter for dates, if the last movement of the the account "xx-xx-xx" was on april 2019, and in 2020 I don't have any movements, it will never be shown with this filter. How could I indicate that I want to continue showing the accounts with the final balance <>0, in order to have the real balance in each filtered period?
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@yingyinr Hi, I fixed it with:

Saldo inicial1 =
VAR __Account = MAX([CTA_CONTABLE])
VAR __MinDate = MINX(FILTER('3Saldo ini','3Saldo ini'[CTA_CONTABLE] = __Account),[PERIODO])
RETURN
CALCULATE(SUM('3Saldo ini'[SALDO_INICIAL]),filter( '3Saldo ini','3Saldo ini'[CTA_CONTABLE] = __Account && [PERIODO] = __MinDate ))
 
I was selecting wrong the columns
Thank you so much
 

Kind regards

Eduardo Silva

View solution in original post

6 REPLIES 6
PaulDBrown
Community Champion
Community Champion

@Anonymous 

You might want to explore the functions available, such as OPENINGBALANCEMONTH

 

https://dax.guide/openingbalancemonth/ 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

@PaulDBrown thank you Paul, but how could I applied it if I could filtered by different periods of time

eduardosilvin_0-1601638484286.png

(account - open balance - debits - credits - final balance)

Hi @Anonymous ,

I'm sorry that I still have some confusion about your requirement. Could you please provide more sample data and explain your problem&desired result with specific data examples? And could you please list the fields/measures which applied in Matrix and slicer? Are they from the same table?


My problem is when I filter for dates, if the last movement of the the account "xx-xx-xx" was on april 2019, and in 2020 I don't have any movements, it will never be shown with this filter. How could I indicate that I want to continue showing the accounts with the final balance <>0, in order to have the real balance in each filtered period?


Best Regards

Rena

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

@yingyinr Hi, I fixed it with:

Saldo inicial1 =
VAR __Account = MAX([CTA_CONTABLE])
VAR __MinDate = MINX(FILTER('3Saldo ini','3Saldo ini'[CTA_CONTABLE] = __Account),[PERIODO])
RETURN
CALCULATE(SUM('3Saldo ini'[SALDO_INICIAL]),filter( '3Saldo ini','3Saldo ini'[CTA_CONTABLE] = __Account && [PERIODO] = __MinDate ))
 
I was selecting wrong the columns
Thank you so much
 

Kind regards

Eduardo Silva

amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Anonymous
Not applicable

@amitchandak hey, sure:

eduardosilvin_0-1601631966849.png

for example, this account is an asset, when I filter by date, selecting 2019, everything is ok, because my date for this row is 2019, but when I filter any month or the complete year 2020, the problem is that the system doesnt found that account in those dates and my sum of assets doesnt take that account. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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