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
Hassaan1994
New Member

Calculating balance column based on multiple criteria

Hi Everyone! 

 

I'm very new to using Power BI and would really appreciate some help. 

 

I'm trying to calculate a column for balance which shows the remaining amount over due, and should update after the company changes. Currently, the balance column is executing an IF query as follows: 

 

Balance = IF(AND('For BI'[Date]>DATE(2022,9,19),'For BI'[Overdue]>0),('For BI'[Overdue]-'For BI'[Collection]),'For BI'[Overdue])

 

What I want is for the balance amount to update for each company after each date, for example:

 

the balance in row # 5 should be: 11,281-300 (which is the sum of collections after the 19th) 

This should continue until the rows for the current company end and move to the next one.

 

Hassaan1994_0-1664356737813.png

 

I'd be really thankful if someone's able to help out 🙂

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Hassaan1994 

Here are the steps you can follow:

(1)This is my test data:

vyueyunzhmsft_0-1664422574775.png

(2)you can create a calculated column :

Balance = var _current_IPP= 'Sheet1'[IPP Name]
var current_date = 'Sheet1'[Date]
var _sum=SUMX( FILTER('Sheet1','Sheet1'[IPP Name]=_current_IPP && 'Sheet1'[Date] <= current_date && 'Sheet1'[Date] > DATE(2022,9,19)) , [Collection])
return 
[Overdue]-_sum

(3)Then you cna meet your need, the result is as follows:

vyueyunzhmsft_1-1664422618694.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

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

2 REPLIES 2
v-yueyunzh-msft
Community Support
Community Support

Hi , @Hassaan1994 

Here are the steps you can follow:

(1)This is my test data:

vyueyunzhmsft_0-1664422574775.png

(2)you can create a calculated column :

Balance = var _current_IPP= 'Sheet1'[IPP Name]
var current_date = 'Sheet1'[Date]
var _sum=SUMX( FILTER('Sheet1','Sheet1'[IPP Name]=_current_IPP && 'Sheet1'[Date] <= current_date && 'Sheet1'[Date] > DATE(2022,9,19)) , [Collection])
return 
[Overdue]-_sum

(3)Then you cna meet your need, the result is as follows:

vyueyunzhmsft_1-1664422618694.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

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

 

 

Thank you! This works perfectly.

I just added an IF statement after return, to make sure my balance doesn't show below zero. 

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.