cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Helper II

## Calculated Column Based on Max Index of other Column

Hi guys.

I want to create a calculated column based on the Max index number of another column.

Specifically for the table below:

For the combination Attribute 1 - Attribute 2 (ex A-X),  to have the result of the amount (ie 10) next to the max Index ( ie 3),

and the others as blanks.

For B-Z, amount 24 next to Index 6 etc.

Is it possible?

Kostas

1 ACCEPTED SOLUTION
Resolver III

Please try the dax code provided below as a calculated column.

``````Max Amount =
Var Attribute1= 'Table'[Attribute 1]
Var Attribute2= 'Table'[Attribute 2]
Var AttributeFilter = Filter('Table','Table'[Attribute 1] =Attribute1 && 'Table'[Attribute 2] =Attribute2)
Var IndexMax = Calculate(max('Table'[Index]),AttributeFilter)
Var Result = If(IndexMax= 'Table'[Index],'Table'[Amount],BLANK())

Return Result``````

If this doesn't solve your problem please give an update so that I can work on it.

If this post helps, then please consider accepting it as the solution to help the other members find it more quickly.
Regards,
Atma.

3 REPLIES 3
Helper II

Great work!

Thank you @Dhacd

Kostas

Super User

Here the DAX code for the calculated column:

```Result =
IF (
RANKX (
FILTER (
'Table',
'Table'[Attribute1] = EARLIER ( 'Table'[Attribute1] ) && 'Table'[Attribute2] = EARLIER ( 'Table'[Attribute2] )
),
'Table'[Index],
, DESC
, DENSE
) = 1,
Table[Amount],
BLANK()
)```

Let me know if this helps 🙂

 Also happily accepting Kudos 🙂

 Feel free to connect with me on LinkedIn!

 #proudtobeasuperuser

Resolver III

Please try the dax code provided below as a calculated column.

``````Max Amount =
Var Attribute1= 'Table'[Attribute 1]
Var Attribute2= 'Table'[Attribute 2]
Var AttributeFilter = Filter('Table','Table'[Attribute 1] =Attribute1 && 'Table'[Attribute 2] =Attribute2)
Var IndexMax = Calculate(max('Table'[Index]),AttributeFilter)
Var Result = If(IndexMax= 'Table'[Index],'Table'[Amount],BLANK())

Return Result``````

If this doesn't solve your problem please give an update so that I can work on it.

If this post helps, then please consider accepting it as the solution to help the other members find it more quickly.
Regards,
Atma.

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors