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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MarinaEscali
Regular Visitor

Sum of minimal values for categories from 2 columns

Hi, 

I am a rookie in Power BI and I've been sitting for a while whith this problem:

So I have a table that contains loan data payment schedules. (Loan A and B are just some of them). Each loan is payd during several years quarterly, semiannually or annualy and their payment schedule dates differ: 

LoanTransactionDateyearBalance
A07.01.2021202150 000
A07.04.2021202145 000
A07.07.2021202140 000
A07.10.2021202135 000
A07.01.2022202230 000
A07.04.2022202225 000
A07.07.2022202220 000
A07.10.2022202215 000
A07.01.2023202310 000
A07.04.202320235 000
B15.02.20212021120 000
B15.05.20212021110 000
B15.08.20212021100 000
B15.11.2021202190 000
B15.02.2022202280 000
B15.05.2022202270 000
B15.08.2022202260 000
B15.11.2022202250 000
B15.02.2023202340 000
B15.05.2023202330 000
B15.08.2023202320 000
B15.11.2023202310 000

 

Now I want to show the balance at the beginning of the year for each of these loans. I also would like to see the sum of the outstanding balance of all the loans:

 202120222023
A50 00030 00010 000
B120 00080 00040 000
Total170 000110 00050 000

 

I have tried to use min and rank and other combinations. The problem is that they don't sum correctly.

 

For example:

BalanceYear =
VAR First_Date = MIN(Table[TransactionDate])
VAR Balance_Table = CALCULATETABLE(SUMMARIZE(Table,Table[Year],
"Bal", SUM(Table[Balance])), Table[TransactionDate] = First_Date)
RETURN
CALCULATE(SUMX(Balance_Table, [Bal]))
 
Visualizing the dtaa throug a matrix show the expected Balance at the beginning of each year. BUT! The sum field shows the Balance for the minimal TransactionDate (even if the balance is not necessarily the smallest amount)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MarinaEscali 

Please Try this measure:

Measure = 
VAR _T = SUMMARIZE(FILTER('Table','Table'[TransactionDate] = CALCULATE(MIN('Table'[TransactionDate]),FILTER('Table','Table'[Loan] = EARLIER('Table'[Loan])&&'Table'[year]=EARLIER('Table'[year])))),'Table'[Loan],'Table'[TransactionDate],'Table'[year],'Table'[Balance])
Return
IF(HASONEVALUE('Table'[Loan]),SUMX(FILTER(_T,[Loan] = MAX('Table'[Loan])&&'Table'[year] = MAX('Table'[year])),[Balance]),SUMX(FILTER(_T,'Table'[year] = MAX('Table'[year])),[Balance]))

Result is as below.

1.png

Best Regards,

Rico Zhou

 

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

1 REPLY 1
Anonymous
Not applicable

Hi @MarinaEscali 

Please Try this measure:

Measure = 
VAR _T = SUMMARIZE(FILTER('Table','Table'[TransactionDate] = CALCULATE(MIN('Table'[TransactionDate]),FILTER('Table','Table'[Loan] = EARLIER('Table'[Loan])&&'Table'[year]=EARLIER('Table'[year])))),'Table'[Loan],'Table'[TransactionDate],'Table'[year],'Table'[Balance])
Return
IF(HASONEVALUE('Table'[Loan]),SUMX(FILTER(_T,[Loan] = MAX('Table'[Loan])&&'Table'[year] = MAX('Table'[year])),[Balance]),SUMX(FILTER(_T,'Table'[year] = MAX('Table'[year])),[Balance]))

Result is as below.

1.png

Best Regards,

Rico Zhou

 

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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