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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Tito
Helper III
Helper III

Calculate Sum MAX

Hello everyone,

Can someone please help me how to calculate the maximum of Sales. See the data below:

Data:

Data_Max_Sales.PNG


 Result:

Result.PNG


Best regards
Tito

1 ACCEPTED SOLUTION

Hi @Tito,

Please try this formula:

MAX Measure = 

VAR _Table =
     ADDCOLUMNS(
        SUMMARIZE(
            T_MaxQ,
            T_MaxQ[Name],
            T_MaxQ[ID]
        ),
        "@MaxSales",   
		VAR _MAX = CALCULATE(MAX(T_MaxQ[Date]))
		VAR _Result = 
			CALCULATE(
				SUM(T_MaxQ[Sales]),
				T_MaxQ[Date] = _MAX
				
			)
		RETURN
			_Result
    )
VAR _Result = SUMX(_Table, [@MaxSales])
RETURN
    _Result




Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

13 REPLIES 13
Ajithkumar_03
Frequent Visitor

Hi @Tito 

please refer the below measures.

Sample Table:

Ajithkumar_03_0-1714990569090.png


Measure 1:

Ajithkumar_03_1-1714990597778.png

 

Measure 2:

Ajithkumar_03_2-1714990617258.png


Result:

Ajithkumar_03_3-1714990752783.png

 



I hope this measure will help you.

If it solves your issue, please accept it as the solution to help the other members find it more quickly.

Best Regards,
Ajith Kumar

Hi @Ajithkumar_03 

Thank you very much! That worked too. 👍

Best regards

manvishah17
Resolver I
Resolver I

Screenshot 2024-05-06 153203.png

 

Screenshot 2024-05-06 154042.png

 

HI @Tito ,
To get sales by Maximum date you can use this measure,

 

 

SalesByMaxDate = 
CALCULATE(
    SUM('Order Data'[Sales]),
 FILTER('Order Data',
  'Order Data'[Date]
  =MAX('Order Data'[Date])
  )
  )

 

 

Hi @manvishah17 

Thank you!

Best regards

Uzi2019
Super User
Super User

Hi @Tito 
You can try this dax

 

Total = calculate (Sum(Table[sales]), max(Date[date])

 

I hope I answered your question!

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
DataNinja777
Super User
Super User

Hi @_AAndrade 

You can get your required output in the manner below:

DataNinja777_0-1714984937065.png

 

Hi @DataNinja777 ,

Thank you for your reply.
If I select name "A", 30 should be returned. 
I want the sum sales by maximum of date and not the maximum of sales.

Hi @Tito 

Sumxing over ID of the max sales measure will get your required output.  I am not sure why combining in one formula will produce the different result from separating out in two measures like below, but separating out in two measure will get your required output.

Sumxing over ID = sumx(values('Table'[ID]),[Max sales])

DataNinja777_0-1714989674967.png

Best regards,

 

Hi @DataNinja777 ,

Thank you very much! That worked too.

Best regards

_AAndrade
Super User
Super User

Hi @Tito,

Here is my solution:

I'm using this measure:

 

MAX Measure = 
VAR _Table =
    ADDCOLUMNS(
        SUMMARIZE(
            T_MaxQ,
            T_MaxQ[Name],
            T_MaxQ[ID]
        ),
        "@Max", CALCULATE(MAX(T_MaxQ[Sales]))
    )
VAR _Result = SUMX(_Table, [@Max])
RETURN
    _Result

 

 

 

And the final result is this:

_AAndrade_0-1714984368985.png

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Hi @_AAndrade  @DataNinja777 
Thank you for your reply.
I want the sum sales by maximum of date and not the maximum of sales. See example below:

Data:

Data_Max_Sales_2.PNG


Result:

Result_2.PNG

Hi @Tito,

Please try this formula:

MAX Measure = 

VAR _Table =
     ADDCOLUMNS(
        SUMMARIZE(
            T_MaxQ,
            T_MaxQ[Name],
            T_MaxQ[ID]
        ),
        "@MaxSales",   
		VAR _MAX = CALCULATE(MAX(T_MaxQ[Date]))
		VAR _Result = 
			CALCULATE(
				SUM(T_MaxQ[Sales]),
				T_MaxQ[Date] = _MAX
				
			)
		RETURN
			_Result
    )
VAR _Result = SUMX(_Table, [@MaxSales])
RETURN
    _Result




Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Hi @_AAndrade 

Thank you very much! It worked really well.

Best regards

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.