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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Laho
Helper I
Helper I

Calculate Totals of SUM MAX Date

Hi All,

 

I've been struggeling with the totals of SUM MAX Date measure. My Measure looks like this right now. Works as expected in row;

 

LastActiveUsers = CALCULATE(
SUM('Daily licensing'[ActiveUsers]),
FILTER( 'Daily licensing', 'Daily licensing'[ReceivedOn] = MAX('Daily licensing'[ReceivedOn])))

We're receiving several records of the same customer on a day. Thats why I only want the MAX value on that day.

I know there are a lot of articles based on fixing totals within tables. But can't fix this one somehow.

The thing is that the totals needs to be working as well. Table looks as follow;

 

ReceivedOnCustomerActiveUsersLastActiveUsers
08-10-2020 15:01:30A123123
08-10-2020 18:01:30B11
08-10-2020 18:02:35B2121
08-10-2020 09:01:20C55
total 1501

 

Any help would be apreciated.

1 ACCEPTED SOLUTION

Hi @Laho ,

 

Please refer to the following measure:

 

LastActiveUsers = SUMX(SUMMARIZE('Table','Table'[ReceivedOn].[Date],'Table'[Customer],"maxauser",MAX('Table'[ActiveUsers])),[maxauser])

 

 

Capture4.PNG

 

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

 

Best Regards,

Dedmon Dai

 

View solution in original post

9 REPLIES 9
amitchandak
Super User
Super User

@Laho , try like

LastActiveUsers = CALCULATE(
SUM('Daily licensing'[ActiveUsers]),
FILTER( allselcted('Daily licensing'), 'Daily licensing'[ReceivedOn] = MAX('Daily licensing'[ReceivedOn])))

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Thanks,

 

LastActiveUsers = CALCULATE(
SUM('Daily licensing'[ActiveUsers]),
FILTER( allselcted('Daily licensing'), 'Daily licensing'[ReceivedOn] = MAX('Daily licensing'[ReceivedOn])))

This returns the max value, but inline it returns the max value overall 😉 so 123 in each row

Hi @Laho ,

 

Would you please try the following measure:

 

 

LastActiveUsers = CALCULATE(MAX('Table'[ActiveUsers]),FILTER(ALL('Table'),'Table'[Customer] in DISTINCT('Table'[Customer])))

 

 

Capture.PNG

 

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

 

Best Regards,

Dedmon Dai

Hi Dedmo,

 

Thanks for your reply. 

LastActiveUsers = CALCULATE(MAX('Table'[ActiveUsers]),FILTER(ALL('Table'),'Table'[Customer] in DISTINCT('Table'[Customer])))

This is returning the MAX value for the table. So in youre screenshot 123. But what i need is that i need the MAX of customer on day x. So right now my info is delivered this way:

 

ReceivedOnCustomerActiveUsers
08-10-2020 15:01:30A123
08-10-2020 18:01:30B1
08-10-2020 18:02:35B21
08-10-2020 09:01:20C5
total 150

 

I want to create a calculation that only the max over customer is picked of date x. So in this case this records should be included:

 

ReceivedOnCustomerLastActiveUsers
08-10-2020 15:01:30A123
08-10-2020 18:02:35B21
08-10-2020 09:01:20C5
total 149


The current calculations all do work inline but are returning icorrect totals:

LastActiveUsers = CALCULATE(
SUM('Daily licensing'[ActiveUsers]),
FILTER( 'Daily licensing', 'Daily licensing'[ReceivedOn] = MAX('Daily licensing'[ReceivedOn])))
CALCULATE(
MAX('Daily licensing'[ActiveUsers]),
All(Daily Licensing),Values('Daily licensing'[ActiveUsers])
 
 

Hi @Laho ,

 

Please refer to the following measure:

 

LastActiveUsers = SUMX(SUMMARIZE('Table','Table'[ReceivedOn].[Date],'Table'[Customer],"maxauser",MAX('Table'[ActiveUsers])),[maxauser])

 

 

Capture4.PNG

 

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

 

Best Regards,

Dedmon Dai

 

Hi Dedmon,

 

It looks like this is the solution! Thanks a lot. 
Can you clairify the solution for me? 

maxauser

 

Laurens, 

Hi @Laho ,

 

I create a summary table and get the maximum ActiveUsers for each customer.

 

Best Regards,

Dedmon Dai

VijayP
Super User
Super User


LastActiveUsers = CALCULATE(
MAX('Daily licensing'[ActiveUsers]),
All(Daily Licensing),Values('Daily licensing'[ActiveUsers])

  @Laho Trythis  and let me know  and share your Kudoes




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Thanks,

 

CALCULATE(
MAX('Daily licensing'[ActiveUsers]),
All(Daily Licensing),Values('Daily licensing'[ActiveUsers])

This wil get the MAX value from the table. So 123 in this case.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.