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
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
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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