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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Getting MIN from related table

I have a fact table with a connection to a dimension table (with key_fact and Key_dim). In the dimension table I have a column which has diffrenet delivered code from 1 to 5 and I need to write a dax code to select keys from fact table which has the minimum code; those which has delivered=1.

 

Here is how 'delivered' column looks like in dimension table:

 

122.PNG

 

I'm a little confused about which function should be used, lookupvalue, related,..:

 

 

delivered status:=

Var Result = calculate(
                     MIN('dim1'[delivered])
                    ,filter('fact'
                           ,RELATED('dim1'[key_dim])
                           )
                          
                       )

Return Result

 

  

8 REPLIES 8
Tahreem24
Super User
Super User

@Anonymous ,

Enhance your measure like this:

delivered status:=

Var Result = calculate(
                     MIN('dim1'[delivered])
                    ,filter('fact'
                           ,RELATED('dim1'[key_dim]) = MIN('fact'[Key_fact])
                           )
                          
                       )

Return Result
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

key_dim and key_fact are two sequence numbers in each table and I need to select minimum on delivered column not on keys.

 

I could resolve the issue somehow.

Anonymous
Not applicable

Hi @Anonymous 

Do you want to get key_fact in Fact Table by the minimum on delivered column in DimTable?

Due to I don't know about your data model, I build a sample to have a test.

Dim table

1.png

Fact:

2.png

If your relationship is one to one try to build a slicer by delivered, when you select 1, you can get the result.

If your relationshop is one to many, try to build a measure filter and add it into the Filter Field in the table visual.

Set this measure to show items when value =1.

Measure = 
VAR _MINdeliver = MINX(ALL(dim1),dim1[delivered])
VAR _Key_Dim = CALCULATETABLE(VALUES(dim1[Key_Dim]),FILTER(ALL(dim1),dim1[delivered] = _MINdeliver))
RETURN
IF(MAX('Fact'[Key_Fact]) IN _Key_Dim,1,0)

3.png

If this reply still couldn't help you solve your problem, please show me your Fact table and your relationship.

You can show me a screenshot of the result you want, it will make it easier for me to understand your requirement.

 

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. 

 

Anonymous
Not applicable

@Anonymous Thank you for your answer.

It's an standard report which customer use and I can't add filter or slicer, it should be a measure. Using a measure as a filter in report would affect the other measure I've used and would show incorrect value.

 

Anonymous
Not applicable

Hi @Anonymous 

Could you share a sample with me by your Onedrive for Business?

This will make it easier for me to understand your requirement.

 

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. 

Anonymous
Not applicable

Thank you @Anonymous I could somehow resolve the issue by changing SQL view which tabular reading from.

Anonymous
Not applicable

Hi @Anonymous 

I am so glad that your problem could be solved.

Could you kindly Accept the helpful reply as the solution? More people will benefit from it. 

 

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. 

 

Anonymous
Not applicable

@Anonymous Thanks for your reply but as I wrote using the measure as filter in report will affect other measures which is used in report and I had to change the sql view on DB side. In your example there isn't any other measure related to dim1[delivered] and I'm sure that you can't get this answer without any affect on other measures in your report.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.