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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Count and Filter in DirectQuery where Product Count greater than "n"

Hello All,

 

following situation:

 

We have a table like

ProductCategory | Product

A | A1

A | A2

A | A3

B | B1

B | B2

 

Now I want to show only ProductCategory where Count(Product) > 2, e.g. ProductCategory A

 

Is there any chance to do this in DirectQuery Mode (and not to use Power Query Editor)

 

I could think of possible solutions in Import Mode (e.g. New Column with Calculate etc) but in DirectQuery?

 

Thanks and Best Regards

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

There isn't any context in the Page or Report Level filters. So we can't use a measure there. There is a workaround. You can add a new table like below and use a measure instead. Please refer to the snapshot below.

1. A new table.

N

1
2
3

2. Create a measure.

 

Measure =
VAR countProduct =
    COUNT ( directquery[Product] )
RETURN
    IF ( countProduct > MIN ( Table1[N] ), countProduct, BLANK () )

3. Add the new column in a Page or Report filter.

 

 

Count and Filter in DirectQuery where Product Count greater than n2.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards,

Community Support Team _ Dale
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

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

 

This measure should work

 

Measure1 = if(COUNTROWS(Data)>2,COUNTROWS(Data),BLANK())

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

HI @v-jiascu-msft ,

 

very interesting solution. It works but produces a huge join (if used with a real table), which results in the 1Mio Row Problem (Thought this would only relate to the result set shown, but seems to make problems if the join result is > 1 Mio. even in the background)

 

@Ashish_MathurI Can not use this in a Report or Page Filter.

 

Thanks for your help.

 

Best Regards

 

v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

It seems the "n" is static. How about the filters? Please refer to the snapshot below.

Count-and-Filter-in-Direct-Query-where-Product-Count-greater-than-n

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi,

 

thanks for your response.

Tthis is possible in Visual Level Filter only.

I am looking for a solution for Page or Report Level.

 

Best regards

 

 

Hi @Anonymous ,

 

There isn't any context in the Page or Report Level filters. So we can't use a measure there. There is a workaround. You can add a new table like below and use a measure instead. Please refer to the snapshot below.

1. A new table.

N

1
2
3

2. Create a measure.

 

Measure =
VAR countProduct =
    COUNT ( directquery[Product] )
RETURN
    IF ( countProduct > MIN ( Table1[N] ), countProduct, BLANK () )

3. Add the new column in a Page or Report filter.

 

 

Count and Filter in DirectQuery where Product Count greater than n2.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards,

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors