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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mowmassimow
New Member

Show visual only if number of rows are below x

Hi,

 

I have actually a fairly simple problem:

 

I want to show a visual (e.g. table) only if the amount of rows (->COUNT(TABLE[ID])) is below a certain number. If the number of rows is above this number, the table should not be shown/calculated.

 

I already created multiple different measures and added them to filters etc. but it always ends up the same way: Power BI tries to show the whole table (and then breaks because out of memory) before doing the check like described above.

 

Things that are not an option for us:

- Direct query

- Simplifying the visual, as there are just columns from one table without any measure or calculated table

 

Thanks in advance!

 

Best,
Moritz

5 REPLIES 5
mowmassimow
New Member

Hi @v-xianjtan-msft,

thanks for your answer.

COUNTROWS() might perform better in general, but it doesn't fix the core issue: Checking the condition (count less than X), before calculating the whole table.

 

Best,
Moritz

v-xianjtan-msft
Community Support
Community Support

Hi @mowmassimow 

 

Please try using COUNTROWS instead of COUNT.  

Use COUNTROWS instead of COUNT in DAX - DAX | Microsoft Learn

Use this measure as a filter condition for visual. Set the filter condition to ShowTable = 1.

ShowTable = IF(COUNTROWS(YourTable) < [certain number], 1, 0)

 

If out-of-memory errors still occur, consider optimizing the data model, such as using SQL queries or Power Query to limit data loading to only necessary rows of data.

DirectQuery model guidance in Power BI Desktop - Power BI | Microsoft Learn

 

 

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

Hi @v-xianjtan-msft,

thanks for your answer.

COUNTROWS() might perform better in general, but it doesn't fix the core issue: Checking the condition (count less than X), before calculating the whole table.

 

Best,
Moritz

Hi @mowmassimow 

 

What you said is correct. The logic for calculating this measure is to count the whole table then compare it to the certain number in the condition. Therefore, we recommend that you reduce the amount of data being processed or optimize your data model to avoid running out of memory. If you are using a virtual machine, try allocating more memory.

DirectQuery model guidance in Power BI Desktop - Power BI | Microsoft Learn

 

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

Hi,

as I said, I can not optimize anything in the datamodel or reduce the amaount of data more.

How can it be so difficult to have one simple calculation (countrows), before starting with another calculation???

Best,
Moritz

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.