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
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!

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.