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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
gmasta1129
Helper III
Helper III

Formula to pull max value based off another column

Hello,

 

I would like to pull the maximum number in the "Total" column based off the customer account number. 

My data has thousands of rows. 

I need the maximum value to pull into the new column (see below) and the then the rest of the rows should show 0

 

For example,

I should see in the new column for customer number 5225, the number 10 since that is the highest number

I should see in the new column for customer number 6175, the number 21 sinc that is the highest number. The rest of the rows should show zero. 

I used the following formula in excel but cant figure out how to convert this to Power BI...

=LET(m,MAXIFS($Z$2:$Z$20000,$B$2:$B$20000,$B2), IF($Z2=m,m,0))

 

Customer Account Number     Total      New Column (Maximum Value)

5225                                            0                    0

5225                                          10                  10

5225                                           2                    0

5225                                           2                    0

5225                                           6                    0

6175                                           3                    0

6175                                            7                   0

6175                                            9                   0

6175                                            21                 21

1 ACCEPTED SOLUTION
muhammad_786_1
Resolver V
Resolver V

Hi @gmasta1129 

 

You can try this DAX to get your desire output by create new calculated column.

muhammad_786_1_0-1731612770282.png

 

Best Regards,
Muhammad Yousaf

 

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

 

LinkedIn

 

View solution in original post

3 REPLIES 3
Kedar_Pande
Resident Rockstar
Resident Rockstar

@gmasta1129 

Create a calculated column:

New Column (Maximum Value) =
VAR MaxValue = CALCULATE(
MAX('Table'[Total]),
ALLEXCEPT('Table', 'Table'[Customer Account Number])
)
RETURN IF('Table'[Total] = MaxValue, MaxValue, 0)

This approach will create a column in which only the row with the maximum value for each Customer Account Number shows the max value, while other rows display 0, just like in your Excel formula.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

gmasta1129
Helper III
Helper III

Hello Muhammad,

 

The formula worked. Thank you so much! 

 

muhammad_786_1
Resolver V
Resolver V

Hi @gmasta1129 

 

You can try this DAX to get your desire output by create new calculated column.

muhammad_786_1_0-1731612770282.png

 

Best Regards,
Muhammad Yousaf

 

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

 

LinkedIn

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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