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
suhasakole
Frequent Visitor

SQL to DAX Measure

I am planning to create DAX calculated measure in the PowerBI where Date will be passed as a slicer for the measure and it should return the current headcount of the employee. 

SELECT 

COUNT(DISTINCT A.emplid) AS HEADCOUNT 
FROM 
tbl_EmpHistory  AS A
Inner join (SELECT emplid, MAX(WorkStartedDate) as WorkStartedDate
                  FROM tbl_EmpHistory 
                  Where WorkStartedDate <=  cast('2017-12-31' as Date) -- this data will pass as slicer from PowerBI Dashboard 
            Group by  emplid ) AS B
ON A.emplid = B.emplid
AND A.WorkStartedDate = B.WorkStartedDate
WHERE 
lower(A.type) = 'emp' 

AND A.active = 1

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@suhasakole ,

 

You may take a look at the links below.

Community Support Team _ Sam Zha
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
v-chuncz-msft
Community Support
Community Support

@suhasakole ,

 

You may take a look at the links below.

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

thanks

suhasakole
Frequent Visitor

any help ... much appreciated


@suhasakole wrote:

I am planning to create DAX calculated measure in the PowerBI where Date will be passed as a slicer for the measure and it should return the current headcount of the employee. 

SELECT 

COUNT(DISTINCT A.emplid) AS HEADCOUNT 
FROM 
tbl_EmpHistory  AS A
Inner join (SELECT emplid, MAX(WorkStartedDate) as WorkStartedDate
                  FROM tbl_EmpHistory 
                  Where WorkStartedDate <=  cast('2017-12-31' as Date) -- this data will pass as slicer from PowerBI Dashboard 
            Group by  emplid ) AS B
ON A.emplid = B.emplid
AND A.WorkStartedDate = B.WorkStartedDate
WHERE 
lower(A.type) = 'emp' 

AND A.active = 1



 

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.