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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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