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
jmkvalsund
Helper II
Helper II

MAXX and MINX calculating wrongly on measure

I've made a running total measure (Balance) to my table Transactions like this:

Balance = Calculate(SUM(Transactions[AccountValue]),FILTER(ALL(Transactions[TransactionsDTM]),Transactions[TransactionsDTM]<=MAX(Transactions[TransactionsDTM]))) 
This one works, I've  put the same data in Excel and compared cell by cell, Balance is calculated correct.

Then I'try to find the Max- and Min-value of Balance like this:
Balance MAX = MAXX(ALL(Transactions ),Transactions [Balance])
 
The expression is evaluated and returns data, but the numbers are wrong, in the order of Max supposed to be 19 millions but shows up 21 millions, Min supposed to be -60 millions, shows -90 millions.
 
Any suggestions of where I'm failing?
 
Regards,
John Martin
 
 
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @jmkvalsund ,

 

Can you provide dummy data and expected results?
In the dummy data I created myself, Balance and AccountValue have the same results.

vstephenmsft_0-1644394743161.png

 

Are you trying to calculate the cumulative value?

If so, you can try to remove the fields in the ALL function and modify them as follows.

 

Balance = Calculate(SUM(Transactions[AccountValue]),FILTER(ALL(Transactions),Transactions[TransactionsDTM]<=MAX(Transactions[TransactionsDTM]))) 

 

vstephenmsft_1-1644394803157.png

 

Balance MAX = MAXX(ALL(Transactions),[Balance])

 

vstephenmsft_2-1644394866102.png

 

 

Best Regards,

Stephen Tao

 

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

 

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @jmkvalsund ,

 

Can you provide dummy data and expected results?
In the dummy data I created myself, Balance and AccountValue have the same results.

vstephenmsft_0-1644394743161.png

 

Are you trying to calculate the cumulative value?

If so, you can try to remove the fields in the ALL function and modify them as follows.

 

Balance = Calculate(SUM(Transactions[AccountValue]),FILTER(ALL(Transactions),Transactions[TransactionsDTM]<=MAX(Transactions[TransactionsDTM]))) 

 

vstephenmsft_1-1644394803157.png

 

Balance MAX = MAXX(ALL(Transactions),[Balance])

 

vstephenmsft_2-1644394866102.png

 

 

Best Regards,

Stephen Tao

 

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

 

Thanks a lot, this works!

ValtteriN
Super User
Super User

Hi,

Try changing your RT measure like this:
Calculate(SUM(Transactions[AccountValue]),ALL(Transactions[TransactionsDTM]),Transactions[TransactionsDTM]<=MAX(Transactions[TransactionsDTM])))

Explanation:

RT calculation works also with the filter, but the interaction with external filters is a bit different:

Period RT FILTER =
VAR MaxDate = MAX ( 'Cumulativetotal'[Date] )
RETURN
CALCULATE (
SUM(Cumulativetotal[Value]),
FILTER(ALLSELECTED('Cumulativetotal') ,'Cumulativetotal'[Date] <= MaxDate))

Period RT =
VAR MaxDate = MAX ( 'Cumulativetotal'[Date] )
RETURN
CALCULATE (
SUM(Cumulativetotal[Value]),
'Cumulativetotal'[Date] <= MaxDate,
ALLSELECTED('Cumulativetotal') )
ValtteriN_0-1643991418896.png

Now when we introducte a filter this happens:

ValtteriN_1-1643991630995.png

I suspect this might be the reason your MAXX is not working properly.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi, I tried your suggestion, but the result is still the same.
But then I narrowed down my datasource to contain just a few records, and now I see whats wrong:
The Max- and Min-values are not taken from the RT measure [Balance], but from the values in the column Transactions[AccountValue]...
Why??
The formula doesn't include this column at all, but the RT measure is based upon it. How does MAXX return values from the measure's datasource instead of the measure's values??

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.

Top Solution Authors