Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

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...
  • v-yulgu-msft's avatar
    8 years ago

    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.

     

    Best regards,

    Yuliana Gu

  • Thejeswar's avatar
    8 years ago

    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