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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Find value from related table based on extra filter conditions

Hi,

 

I have been working with PBI for over 2 years, but really can't find a solution to a seemingly simple problem.

I have 2 tables: 'Customers' and 'Invoices' which are related 1 to * based on [CustomerID]. The 'Invoices' table has besides [CustomerID] also [InvoiceID], [Amount] and [InvoiceDate] as columns. I now want to add a calculated column to 'Customers' which has is the [InvoiceID] of the most recent [InvoiceDate] with an [Amount] > x . 

Any help on how to construct the DAX formula would be highly appreciated!

2 REPLIES 2
Arul
Super User
Super User

@Anonymous ,

It would be better if you share some sample data or the shcema?

Thanks,

Arul





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


Anonymous
Not applicable

Hi @Arul , thanks for reviewing my question, and I indeed should have included some sample data to give a better picture of the problem. But I think I just solved it:


LatestInvoice =
var LatestInvoiceDate = CALCULATE(max(Invoices[InvoiceDate]),Invoices[Amount] > x)
var InvoiceNo = CALCULATE(SELECTEDVALUE(Invoices[InvoiceID]),Invoices[InvoiceDate]=LatestInvoiceDate)
return
InvoiceNo
 
At least it seems to work. I would have expected that a more elegant solution was possible (probably is) based on RELATEDTABLE, but I just couldn't make it work.
Anyway, sorry to have bothered you.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors