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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
bilearner12
Regular Visitor

How to trace back account balance based on previous shopping dates

I have my own personal finance database, which I am using to generate reports of my personal finances.

 

1. Account Balance table:

bilearner12_0-1669713048109.png

2. Account Expenses table:

bilearner12_1-1669713114055.png

 

As you can see, balance table only includes the last refresh date. I want to make a visual on Power BI:

- add expense amounts on the latest account balance
- should be filterable according to dates, not just latest refresh date

 

I tried to create a measure:

Balance_Shift = CALCULATE(VALUES(isbank_account_balance[balance_amount]), isbank_account_balance[balance_id] = 1) + SUM(account_expenses[spent]) - SUM(account_income[amount])


and I used Date column of the account expenses in the line chart, but it didn't work. How can I trace back my account balance?

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @bilearner12 ,


//Balance_Shift = CALCULATE(VALUES(isbank_account_balance[balance_amount]), isbank_account_balance[balance_id] = 1) + SUM(account_expenses[spent]) - SUM(account_income[amount])

It seems that the data above is missing this part of the data.
Please try like:

Measure =
VAR _id = MAX('isbank_account_balance'[balance_id])
VAR _date = MAX('isbank_account_balance'[last_transction_date])
VAR _time = MAX('isbank_account_balance'[last_transction_time])
VAR _spent = CALCULATE(SUM('account_expenses'[spent]),FILTER(ALL('account_expenses'),'account_expenses'[buyDate]<=_date&&'account_expenses'[buyTime]<_time&&'account_expenses'[expenseld]=_id))
VAR _income = CALCULATE(SUM('account_income'[amount]),FILTER(ALL('account_income'),'account_income'[Date]<=_date&&'account_income'[Time]<_time&&'account_income'[ld]=_id))
VAR _result = SUM('isbank_account_balance'[balance_amount]) + _spent - _income
RETURN
_result


then please create a table visual and put this measure and 'isbank_account_balance'[balance_id] in the table.

If this does not work, please consider providing sample files and expected output.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

I tried your solution but it is not working..

 

My all data is here:

https://drive.google.com/drive/folders/1b2AZiQkYTlWmw-X2RrrCXTJsFCqSD-nw?usp=sharing

 

I used your measure:

bilearner12_0-1669883508681.png

And here, it dropped balance_id = 1 (I don't know why)..Shouldn't it use the transaction (expense or income) dates to filter ?

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.