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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Syndicate_Admin
Administrator
Administrator

Support for maximum measurement calculation and obtaining adjacent data from a table.

Hello everyone.

Would you be so kind to help me with these DAX measures:

I try to calculate a DAX formula to get the MAX value of a column and get other values from the same table (summary table, shown below called Summary) is sorted by No Order (shown in red box), and I need to calculate the maximum value of (Ton Desc Mat, shown in blue box) and then get the material values (shown in orange box) and STD (shown in green box).

In the following example, there is an Order 3472 (red box), it has 2 rows (2 different materials), and then I need to calculate the maximum ton desc mat; in this case it is 4,802.56 (blue box), and get the values of STD (7,500 in green box) and Material (Bauxite in Orange box) in different columns.

Thank you in advance for your help.

Best regards

dax measures.png

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Syndicate_Admin 

Thanks for your screenshot sample data . According to your description, you want to get the max value per No.

Here are the steps you can refer to :

(1)This is my test data;

vyueyunzhmsft_0-1686904061608.png

(2)We can create Three measures above it :

Max Tons = var _t = SUMMARIZE( ALLSELECTED('Table') , 'Table'[No.] ,'Table'[Buque] , 'Table'[Cliente] , 'Table'[Material] ,'Table'[Muelle],'Table'[Tipo Operation] , 'Table'[Fecha] , "Tons" , [Tons Desc Mat Measure] , "STD" , [STD Measure])
var _cur_no =  MAX('Table'[No.])
var _t2 = FILTER( _t , [No.] =_cur_no)
return
MAXX(_t2 , [Tons])
Max Material = var _t = SUMMARIZE( ALLSELECTED('Table') , 'Table'[No.] ,'Table'[Buque] , 'Table'[Cliente] , 'Table'[Material] ,'Table'[Muelle],'Table'[Tipo Operation] , 'Table'[Fecha] , "Tons" , [Tons Desc Mat Measure] , "STD" , [STD Measure])
var _cur_no =  MAX('Table'[No.])
VAR _MAX_TONS= [Max Tons]
var _t2 = FILTER( _t , [No.] =_cur_no && [Tons] = _MAX_TONS)
return
MAXX(_t2 , [Material])
Max STD = var _t = SUMMARIZE( ALLSELECTED('Table') , 'Table'[No.] ,'Table'[Buque] , 'Table'[Cliente] , 'Table'[Material] ,'Table'[Muelle],'Table'[Tipo Operation] , 'Table'[Fecha] , "Tons" , [Tons Desc Mat Measure] , "STD" , [STD Measure])
var _cur_no =  MAX('Table'[No.])
VAR _MAX_TONS= [Max Tons]
var _t2 = FILTER( _t , [No.] =_cur_no && [Tons] = _MAX_TONS)

return
MAXX(_t2 , [STD])

 

Then we can put the measures on the visual and we can get the result :

vyueyunzhmsft_1-1686904137005.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Thanks Dijo Zhang for your help !!!

v-yueyunzh-msft
Community Support
Community Support

Hi , @Syndicate_Admin 

Thanks for your screenshot sample data . According to your description, you want to get the max value per No.

Here are the steps you can refer to :

(1)This is my test data;

vyueyunzhmsft_0-1686904061608.png

(2)We can create Three measures above it :

Max Tons = var _t = SUMMARIZE( ALLSELECTED('Table') , 'Table'[No.] ,'Table'[Buque] , 'Table'[Cliente] , 'Table'[Material] ,'Table'[Muelle],'Table'[Tipo Operation] , 'Table'[Fecha] , "Tons" , [Tons Desc Mat Measure] , "STD" , [STD Measure])
var _cur_no =  MAX('Table'[No.])
var _t2 = FILTER( _t , [No.] =_cur_no)
return
MAXX(_t2 , [Tons])
Max Material = var _t = SUMMARIZE( ALLSELECTED('Table') , 'Table'[No.] ,'Table'[Buque] , 'Table'[Cliente] , 'Table'[Material] ,'Table'[Muelle],'Table'[Tipo Operation] , 'Table'[Fecha] , "Tons" , [Tons Desc Mat Measure] , "STD" , [STD Measure])
var _cur_no =  MAX('Table'[No.])
VAR _MAX_TONS= [Max Tons]
var _t2 = FILTER( _t , [No.] =_cur_no && [Tons] = _MAX_TONS)
return
MAXX(_t2 , [Material])
Max STD = var _t = SUMMARIZE( ALLSELECTED('Table') , 'Table'[No.] ,'Table'[Buque] , 'Table'[Cliente] , 'Table'[Material] ,'Table'[Muelle],'Table'[Tipo Operation] , 'Table'[Fecha] , "Tons" , [Tons Desc Mat Measure] , "STD" , [STD Measure])
var _cur_no =  MAX('Table'[No.])
VAR _MAX_TONS= [Max Tons]
var _t2 = FILTER( _t , [No.] =_cur_no && [Tons] = _MAX_TONS)

return
MAXX(_t2 , [STD])

 

Then we can put the measures on the visual and we can get the result :

vyueyunzhmsft_1-1686904137005.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.