cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Regular Visitor

## Urgent help on DAX - MAX index

Dear Power BI Pros,

I need your urgent help on finding the max value.

I want to get the index of max KG.
KG is my measure.

Thank you!

2 ACCEPTED SOLUTIONS
Super User

Hi, @Newbie12345

Regular Visitor

Dear @tamerj1 ,

Thank you so much for your response!
KG is not a column, it is a measure, could pls you suggest me how to pass KG measure inside calculatetable.

8 REPLIES 8
Super User

Expected Output =
VAR T =
GENERATE (
VALUES ( 'Table'[Category] ),
CALCULATETABLE (
TOPN ( 1, SUMMARIZE ( 'Table', 'Table'[Kg], 'Table'[Index] ), 'Table'[Kg] ),
ALLEXCEPT ( 'Table', 'Table'[Category] )
)
)
RETURN
MAXX ( T, 'Table'[Index] )

Regular Visitor

Dear @tamerj1 ,

Thank you so much for your response!
KG is not a column, it is a measure, could pls you suggest me how to pass KG measure inside calculatetable.

Super User

Expected Output =
VAR T =
GENERATE (
VALUES ( 'Table'[Category] ),
CALCULATETABLE (
TOPN ( 1, SUMMARIZE ( 'Table', 'Table'[Index] ), [Kg] ),
ALL ( 'Table'[Index] )
)
)
RETURN
MAXX ( T, 'Table'[Index] )

Regular Visitor

Dear @tamerj1 ,

Thank you so much, I will try this.

Solution Supplier

To find the index of the maximum value of a measure in Power BI, you can use the DAX function MAXX along with FILTER to iterate through the table and find the row with the highest ‘KG’ value. Here’s an example of how you might write this measure:

```MaxKGIndex =
VAR MaxKGValue = MAXX(ALL(Table1), [KG])
RETURN
CALCULATE(
MIN(Table1[Index]),
FILTER(
ALL(Table1),
[KG] = MaxKGValue
)
)```

This measure calculates the maximum ‘KG’ value across all rows in ‘Table1’ and then finds the corresponding ‘Index’ where this maximum value occurs. The ALL function is used to remove any filters that might limit the rows being evaluated. Remember to replace ‘Table1’ with the actual name of your table.

Please note that if there are multiple rows with the same maximum ‘KG’ value, this measure will return the smallest index among them. If you need further assistance or have more specific requirements, feel free to ask! 😊

Regular Visitor

Dear @AnalyticsWizard
Thank you so much for your response.
I tried it, unfortunately it is saying 'Visual is exceeded the available resourses' even after selecting single category.

Super User

Hi, @Newbie12345

Regular Visitor

Dear @Dangar332 ,

Thank you so much!

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors