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
hutch08
Regular Visitor

Running Total along Rank as calculated measure taking too long or out of memory issue

I hope I can find someone to help with this.

 

I want to calculate a running total across a calculated measure ranked list of customers. I use a calculated measure for the ranked list so that I can change it dynamically with filters (as opposed to using a calculated column).

 

the calculated measure for ranking is as follows:

 

Customer Rank = 
   RANKX(
      ALLSELECTED('Revenue Data'[Customer]),
      CALCULATE(
         IF(
            SUM('Revenue Data'[Quantity]) > 0, 
            SUM('Revenue Data'[Sale Amount])/(SUM('Revenue Data'[Quantity]), 
            0)
      ),,
      ASC
)

 

 

The above evaluates fine, but when I try and use the following calculated measure to define the running total of inventory along this ranked customer list it takes a long time to evaluate and sometimes results in out of memory issue.

 

The Running Total measure is calculated as follows:

 

Running Total in Customer Rank = 

VAR
   maxRank = [Customer Rank]
RETURN

CALCULATE(
   SUM('Revenue Data'[Quantity]),
   FILTER(
      ALLSELECTED('Revenue Data'[Customer]),
      [Customer Rank] =< maxRank
   )
)

 

I have tried looking at this in Dax Studio, and it clearly has an issue with this running total measure. I believe it is getting stuck evaluating something that it doesn't need to, but I can't figure out how to drill down deeper and see exactly what is wrong.

 

Just to bring this together so you understand my end goal, I want to use this running total to plot customer purchases in an XY chart where the-y value is the particular customers Average purchase price, the x value is the running total in quantity purchased at that customer, and from left to right the customers are ordered from lowest average purchase price to highest average purchase price. Example in image below:

 

Screen Shot 2018-06-22 at 11.55.32 AM.png

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @hutch08

The second measure invokes another measure which contains specific filter and calculations, it may cause to filters conflict and looping calculation.

Some reference links:

Optimizing DAX expressions involving multiple measures.

Nested Measure Performance

 

Best Regards

Maggie

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.