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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Floriankx
Solution Sage
Solution Sage

Get the value depending on the Max of a range of rows

Hello,

 

I'm trying to get a value depending on the Max value of a different column.

 

Project; Order; Value; Date

A; 123; 1,000,000; 7/31/2016

A; 124; 50,000; 6/15/2016

B: 125; 2,500,000; 1/11/2017

B: 126; 250,000; 3/30/2017

 

I want to show the sum of order values for each project depending on the highest order value inside the project.

 

Result should be:

Project; Value; Date

A; 1,050,000; 7/31/2016

B; 2,750,000; 1/11/2017

 

The sum I get with Sum([Value]) but I'm really struggling to get the date of the highest order.

 

I hope you can help me

1 ACCEPTED SOLUTION
Abduvali
Skilled Sharer
Skilled Sharer

Hi @Floriankx,

 

You need to complete the following steps:

Create new column:

  • New Order Date = if((if(Sheet6[Sales]>=(CALCULATE(MAX(Sheet6[Sales]),ALLEXCEPT(Sheet6,Sheet6[Customer]))),1,0))>0,Sheet6[Start],BLANK())
  • Then you will use this column to display your order date and you will need to filter visual by this column
  • Capture35.PNG
  • And you will also require a measure to give you running total as SUM will not work in this instance
    • Sales running total in Customer =
            CALCULATE( SUM('Sheet6'[Sales]),
                      FILTER(ALL('Sheet6'[New Order Date]),
                                    ISONORAFTER('Sheet6'[New Order Date], MAX('Sheet6'[New Order Date]), DESC)
                                    )
                                 )

I'm sure there is a better way of doing this by using Group By Function but this should work as well, let me know how you get on or if you have any other questions.

 

 

Regards

Abduvali

View solution in original post

1 REPLY 1
Abduvali
Skilled Sharer
Skilled Sharer

Hi @Floriankx,

 

You need to complete the following steps:

Create new column:

  • New Order Date = if((if(Sheet6[Sales]>=(CALCULATE(MAX(Sheet6[Sales]),ALLEXCEPT(Sheet6,Sheet6[Customer]))),1,0))>0,Sheet6[Start],BLANK())
  • Then you will use this column to display your order date and you will need to filter visual by this column
  • Capture35.PNG
  • And you will also require a measure to give you running total as SUM will not work in this instance
    • Sales running total in Customer =
            CALCULATE( SUM('Sheet6'[Sales]),
                      FILTER(ALL('Sheet6'[New Order Date]),
                                    ISONORAFTER('Sheet6'[New Order Date], MAX('Sheet6'[New Order Date]), DESC)
                                    )
                                 )

I'm sure there is a better way of doing this by using Group By Function but this should work as well, let me know how you get on or if you have any other questions.

 

 

Regards

Abduvali

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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