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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to filter rows with IN operator on subquery that uses GROUP BY HAVING COUNT(*) > 1 (SQL to DAX)

Dear fellow developers,

 

I am quite new to DAX, but familiar with SQL. So I would like to explain what I want to achieve in DAX, using an SQL example:

 

SELECT col1, col2, col3

FROM table1

WHERE col1 IN

(SELECT col1

  FROM table1

  GROUP BY col1

  HAVING COUNT(*) > 1)

 

Thanks in advance!

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps

1.my test table

Table:

vbinbinyumsft_0-1661491925661.png

2. create a new table by below dax formula

Table 2 =
VAR tmp =
    CALCULATETABLE (
        VALUES ( 'Table'[Col1] ),
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[Col1], "Count_Rows", COUNT ( 'Table'[Col2] ) ),
            [Count_Rows] > 1
        )
    )
RETURN
    FILTER ( 'Table', 'Table'[Col1] IN tmp )

vbinbinyumsft_1-1661492049750.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps

1.my test table

Table:

vbinbinyumsft_0-1661491925661.png

2. create a new table by below dax formula

Table 2 =
VAR tmp =
    CALCULATETABLE (
        VALUES ( 'Table'[Col1] ),
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[Col1], "Count_Rows", COUNT ( 'Table'[Col2] ) ),
            [Count_Rows] > 1
        )
    )
RETURN
    FILTER ( 'Table', 'Table'[Col1] IN tmp )

vbinbinyumsft_1-1661492049750.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like the attached.

I hope the attached file can provide some ideas on how to create a solution for your dataset.

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Thank you Jihwan Kim!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.