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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
mblom
Frequent Visitor

Calculate last of dates for related records in related table

As a novice power bi user I am not able to figure this out:

 

Model: minox-artikel.artikelcode = minox-facthrgl.artikelcode and minox-facthrgl.factuurnr = minox-facthkop.factuurnr

 

For each record in minox-artikel I would like to calculate MAX facthkop.factuurdatum

 

2020-06-09_17-43-33.png

 

I tried creating a new measure: 

 

 

LastSalesDate = CALCULATE(MAX('minox-facthkop'[FACTUURDATUM]))

 

 

But when filtering the result for just one minox-artikel record (1005181) the result shows many, seemingly unrelated, records:

2020-06-09_17-49-50.png

 

Can anyone please help me to get the one and only MAX date from minox-facthkop for a given record in minox-artikel?

 

Thanks!!

3 REPLIES 3
amitchandak
Super User
Super User

@mblom , two example how can you move data from one table to another a new column

 

Item Name = RELATED('item'[Brand])
City Name = maxx(FILTER(geography,geography[City Id]=Sales[City Id]),geography[City])

 

or

Item Name = maxx('item',RELATED('item'[Brand]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Where is  that ArtikelCode coming from? Your facthkop table is only filtered by Date table and another table which I couldn't see in your picture.

 

Check your relationship between tables. The direction shows the way that filter can propagate. In this case if you want the ArtikelCode to filter your fact table, the table that contains ArtikelCode column should have a directed way to go to your facthkop table. Otherwise, your facthkop table will not be filtered during the calculation and will always return you the largest date in that table.

 

https://docs.microsoft.com/en-us/analysis-services/tabular-models/relationships-ssas-tabular?view=as...

Reference

Thanks for your reply!

 

To simplify the model:

table Product: this contains a list of products with Productcode as unique key

table Invoice: this contains invoice header records with Invoicenumber as unique key and Invoicedate as one of the other columns

table InvoiceItems: this contains invoice items with (amongst other) Invoicenumber as a reference to Invoice and Productcode as a reference to Product

 

What I try to achieve is: for every record in Product calculate the MAX of Invoicedate in table Invoice.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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 Kudoed Authors