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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Get the max value of a dimension for each element of a second dimension

Hello,

 

I have a data model that consists of three tables, one fact table, and two dimensions. The dimensions are both joined to the Fact with a one-to-many relationship

 

I have been asked to find the max date from one dimension (Dim A) for each element in my second dimension (Dim B). I think I need to use Calculate here but I'm not sure how.

 

Image of a data model

 

 

Sample data

dahrhughes_0-1644006839867.png

dahrhughes_2-1644006946360.png

dahrhughes_3-1644006955575.png

dahrhughes_4-1644006966460.png

 

Goal results

dahrhughes_1-1644006868886.png

 

1 REPLY 1
lbendlin
Super User
Super User

Your indicated expected results cannot be achieved.  Both dimensions (Category and Date) will be aggregated if combined with facts, so you cannot have two rows of B and only one row of A.

What you will need to do is create a measure that crawls through the data model

 

MaxDate = 
var c = ADDCOLUMNS(VALUES(_FactValues[FactKeyA]),"FA",_FactValues[FactKeyA])
var d = ADDCOLUMNS(c,"MD",CALCULATE(max(_DimDate[Date]),Filter(_DimDate,_DimDate[FactKeyA]=[FA])))
return MAXX(d,[MD])

 

See attached for an implementation

lbendlin_1-1644105990725.png

 

Another alternative is to show the raw data, the dimensions without the facts.

 

lbendlin_0-1644103977385.png

See attached.

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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