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

Group by and Having

Hello All,

 

I have a sql query, which I need to mimic in PowerBI.

 

SELECT

COUNT(*), EMP_NAME, EMP_ID, YEAR, MONTH

FROM

EMPLOYEE

GROUP BY

EMP_NAME, EMP_ID, YEAR, MONTH

HAVING

COUNT(*) > 1

 

I have imported the table EMPLOYEE into Power BI.

 

Is it possible to do above query in Power BI

 

Creating a view in the DB is not an option.

 

Thanks in Advance.

2 ACCEPTED SOLUTIONS
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Since you have imported the source EMPLYEE table into Power BI, you can apply filter to it via creating a calculated table with the same logic of above SQL query.

Filter Employee =
FILTER (
    SUMMARIZE (
        EMPLOYEE,
        EMPLOYEE[Emp_Name],
        EMPLOYEE[EMP_ID],
        EMPLOYEE[YEAR],
        EMPLOYEE[MONTH],
        "Count records", COUNTROWS ( EMPLOYEE )
    ),
    [Count records] > 1
)

Besides, when you create the connection string, you can type above SQL Query so that you don't need to load all data records into Power BI.

1.PNG

 

Best regards,

Yuliana Gu

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

Thejeswar
Super User
Super User

@Anonymous and @v-yulgu-msft

Additionaly, Instead of creating a summarize table using DAX, we can also achieve this using Group by Option in Power Query

View solution in original post

2 REPLIES 2
Thejeswar
Super User
Super User

@Anonymous and @v-yulgu-msft

Additionaly, Instead of creating a summarize table using DAX, we can also achieve this using Group by Option in Power Query

v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Since you have imported the source EMPLYEE table into Power BI, you can apply filter to it via creating a calculated table with the same logic of above SQL query.

Filter Employee =
FILTER (
    SUMMARIZE (
        EMPLOYEE,
        EMPLOYEE[Emp_Name],
        EMPLOYEE[EMP_ID],
        EMPLOYEE[YEAR],
        EMPLOYEE[MONTH],
        "Count records", COUNTROWS ( EMPLOYEE )
    ),
    [Count records] > 1
)

Besides, when you create the connection string, you can type above SQL Query so that you don't need to load all data records into Power BI.

1.PNG

 

Best regards,

Yuliana Gu

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

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.