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
indhu
Helper III
Helper III

finding transaction based on latest date - help

Hi all,

 

I have a table as follows 

 

Type              userid       date            amount        balance

---------------------------------------------------

deposit          01         01-01-2018      20                101

withdraw       01          02-01-2018     101               00

deposit          02         02-01-2018      05                 05

deposit         02          02-01-2018      10                 15

 

I want to find the latest balance based on the date for each user. Can somebody please help?

 

Thanks,

Indhu.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Try these 3 measures:

Deposits = CALCULATE(
	SUM('YourTable'[amount]),
	ALL('YourTable'),
	'YourTable'[Type] = "deposit"
)
Withdrawals = CALCULATE(
	SUM('YourTable'[amount]),
	ALL('YourTable'),
	'YourTable'[Type] = "withdraw"
)
Balance = [Deposits] - [Withdrawals]

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Try these 3 measures:

Deposits = CALCULATE(
	SUM('YourTable'[amount]),
	ALL('YourTable'),
	'YourTable'[Type] = "deposit"
)
Withdrawals = CALCULATE(
	SUM('YourTable'[amount]),
	ALL('YourTable'),
	'YourTable'[Type] = "withdraw"
)
Balance = [Deposits] - [Withdrawals]

@Anonymous Thanks for your reply. Sometimes the record doesn't match. I want to find the latest date in spite of the transaction type I want to find the latest date, and get the balance alone. Is that possible?

 

Thanks,

Indhu 

Anonymous
Not applicable

LASTDATE('Table'[DateField])

That formula will provide you with the latest date in a table.  You could put that inside a calculate statement.

This gets the latest date on the whole 😞 not filtering based on the user id. I.e. individually.

 

when I used with condition, 

latestdate = CALCULATE(LASTDATE(table[date]),ALLEXCEPT(table,table[userid]))

still failed as the date column duplicates 😞 

 

Any help is much appreciated @Anonymous.

 

Thanks,

Indhu

Anonymous
Not applicable

In that case, switch LASTDATE to MAX

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.