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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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