Showing results for 
Search instead for 
Did you mean: 
Advocate II
Advocate II

Optimisation of measure (count when more than 1 row)


I have a measure that displays the name of a product if there's just one value and displays the count of items if there's more than one:


    COUNT( Orders[Ordered Item] ) <=1,
    VALUES( Orders[Ordered Item] ),
    COUNT( Orders[Ordered Item] ) & " Items"


So if there are several items with the same order number, it just tells you how many but if there's just one, you see the full name.




Which is useful when you want to drill to the order line level:



The issue is that I run into performance issues with more rows. At the line level and a weeks selected, it slows down and if I select a month, it runs out of memory.


Is there a more optimised way of doing this?


Previously it would just show the first line only and that was fast, but it can be confusing for end users when there's more than one item.


Advocate II
Advocate II

Additional thoughts:


Shouldn't it only do this measure for the rows at the top of the matrix and then load more only once the user scrolls further down? Why does it need more memory for more rows if they're not going to all get loaded anyway?

Here's the data model that's been behaving lately:





I was filtering my table with a customer code held in the 'Customers (Orders)' table. Using the same code from within the 'Orders' table makes the matrix perform much better! Rather than running out of memory, the matrix renders in about a second! (The customer name field is in the 'Customers (Orders)' though so if I needed that I guess I'd need to use the query editor and bring it into the 'Orders' table.)




Can someone explain why one simple relationship is causing these issues though?


I've been trying to work out what is causing the issue with DAX Studio but I've not used it before so I'm not sure if this is correct:




Strangely, if I change the customer code column here between Orders[CUSN] and 'Customers (Orders)'[CUSN20], it only makes a 3-4% difference in FE time.

Helpful resources

Power BI Show Ep 4 Post Show Carousel.jpg

The Power BI Community Show

Shabnam Watson demos Incremental refresh & Hybrid Tables and Leila Etaati demos Charticulator.

PBI April Release 2022 768x460.png

Check it out!

Click here to read more about the April 2022 updates!

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!