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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
pedroccamaraDBI
Post Partisan
Post Partisan

Balance difference between two dates (power query, or...)

Hello everyone. I hope everyone's ok.

I need to check the balance difference between the dates selected on the filter. I have the filter for year and also for months.
That means, last balance - first balance, maybe something like, balance (MAX(dates)) - balance(MIN(Dates)), maybe.
My table is like this:
Capture.JPG
Every row will have another column that identifies the type of income or costs like, clients of suppliers for example. And that's what i will need. I will need to know the balance diff for clientes, suppliers, etc.
I really hope you guys can help me
Thanks a lot
Pedro

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @pedroccamaraDBI 

Is column balance a measure? then you want to get the last balance and first balance of the selected period?
if yes, one quick example bellow,

in the example, date between 2016/1/1, 2016/1/25. then I create a slicer and set the period 

v-xiaotang_0-1623823015717.png

then, create the measure,

Measure = 
var _mindate=CALCULATE(MIN('Table'[orderdate]),ALLSELECTED('Table'))//get the min date of selected period
var _maxdate=CALCULATE(MAX('Table'[orderdate]),ALLSELECTED('Table'))
var _firstbalance=CALCULATE([balance],ALLSELECTED('Table'),'Table'[orderdate]=_mindate)// get the firstbalance of selected period
var _lastbalance=CALCULATE([balance],ALLSELECTED('Table'),'Table'[orderdate]=_maxdate)
return _lastbalance-_firstbalance

v-xiaotang_1-1623823129748.png

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution✔️ to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-xiaotang
Community Support
Community Support

Hi @pedroccamaraDBI 

Is column balance a measure? then you want to get the last balance and first balance of the selected period?
if yes, one quick example bellow,

in the example, date between 2016/1/1, 2016/1/25. then I create a slicer and set the period 

v-xiaotang_0-1623823015717.png

then, create the measure,

Measure = 
var _mindate=CALCULATE(MIN('Table'[orderdate]),ALLSELECTED('Table'))//get the min date of selected period
var _maxdate=CALCULATE(MAX('Table'[orderdate]),ALLSELECTED('Table'))
var _firstbalance=CALCULATE([balance],ALLSELECTED('Table'),'Table'[orderdate]=_mindate)// get the firstbalance of selected period
var _lastbalance=CALCULATE([balance],ALLSELECTED('Table'),'Table'[orderdate]=_maxdate)
return _lastbalance-_firstbalance

v-xiaotang_1-1623823129748.png

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution✔️ to help the other members find it more quickly.

Fowmy
Super User
Super User

@pedroccamaraDBI 

You can add a new column to your table as follows and it will show the difference between Debit and Credit. You should be able to filter by Client and Supplier as well.

Balance = Table[Debit] - Table[Credit]

 


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hello @Fowmy 
Thank you for your answer but it's not what i asked and that column is already there

@pedroccamaraDBI 

Then, kindly provide more details and sample data with the expected results.

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy i believe my sample above is enough to get the 2 measures i need : the balance of the min date selected in filter dates, and the balance of the max date selected. Am i missing something?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors