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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
refint650
Helper III
Helper III

SQL Group b to Dax measure for row count

Hello

how to translate this sql group by condition to dax measure to find distinct employee count based on selected value from slicers

select distinct id, name, date, location, count(1) from table a. group by  id, name, date, location

 

Thanks

Vs

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

you get that for free in Power BI.  It automatically aggregates/groups.

 

Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. Screenshots of your source data are not useful.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

View solution in original post

2 REPLIES 2
refint650
Helper III
Helper III

This measure worked for calculating the distinct row count for a group by statement

 

RowCount =

VAR table1 =

    CALCULATETABLE (

        Employee,

        DISTINCT (

            SELECTCOLUMNS (

                Employee,

                "ID", Employee[ID],

                "Name", Employee[Name],

                "Date", Employee[Date]

            )

        )

    )

RETURN

    CALCULATE (

        DISTINCTCOUNT ( Employee[ID] ),

        FILTER ( table1, Employee = 'USA' )

    )

 

or

 

var emp = group by ( table, column1, column2, column 3 )

return calculate (distinctcount(id),  filter(emp, filter condition column expression)

 

lbendlin
Super User
Super User

you get that for free in Power BI.  It automatically aggregates/groups.

 

Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. Screenshots of your source data are not useful.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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