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 Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

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

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors