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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

How do I get the difference of balances between dates?

Hello,

 

I am trying to figure out a way to calculate the difference in balances when I select multiple dates in my slicer. For example, if balance in 12/31/2023 was 11m and balance in 1/31/2024 is 12m I would like to see a difference of 1m be the output. 

Power5_0-1708987197851.png

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table and a retionship (Many to One and Single) from the ProdDate column of your Data Table to the Date column of the Calendar Table.  To your slicer, drag the Date column from the Calendar Table and select 2 dates.  Write these measures

Total = sum(Data[Amount])

Total on first date = calculate([Total],datesbetween(Calendar[date],min(calendar[date]),min(calendar[date])))

Total on second date = calculate([Total],datesbetween(Calendar[date],max(calendar[date]),max(calendar[date])))

Variance = [Total on first date]-[Total on second date]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
_AAndrade
Super User
Super User

It's not wrong the number on the card visual. It's the context where DAX is being evaluated.
If I select 31-01-2024 date on my table the card will show the correct number like this:

_AAndrade_0-1708991218373.png

The Dax measure I used it's to calculate the Balance of the previous month of each date that you have on the visual. It's working to the table matrix and bar chart.







Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table and a retionship (Many to One and Single) from the ProdDate column of your Data Table to the Date column of the Calendar Table.  To your slicer, drag the Date column from the Calendar Table and select 2 dates.  Write these measures

Total = sum(Data[Amount])

Total on first date = calculate([Total],datesbetween(Calendar[date],min(calendar[date]),min(calendar[date])))

Total on second date = calculate([Total],datesbetween(Calendar[date],max(calendar[date]),max(calendar[date])))

Variance = [Total on first date]-[Total on second date]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

I fixed the measures. However; my card that I want to show for the variance does not pull back correct number. IT only returns the balance for the max date but not the difference between the min and max date selected in slicer. 

See Below:

Power5_0-1709054648392.png

 

Share the download link of the PBI file and show the problem there clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Total on first date and total on second date are invalid functions. It says "too few arugments were passed to the DATESBETWEEN function.

_AAndrade
Super User
Super User

Hi,
As far as I can see, you are using implicit measures, and to do what you want you need to use explicit measures.
I did a quick example in my pbi desktop and have this results:

_AAndrade_0-1708988792734.png

I'm using this two measures:

_AAndrade_1-1708988831237.png_AAndrade_2-1708988845622.png

 

 







Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Anonymous
Not applicable

It returns this. I want the 116,899.82 to show up in the card but it shows the grand total instead in the card which is way off by the way.

Power5_0-1708990846703.png

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors