Forum Discussion
suhasakole
7 years agoFrequent 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
You may take a look at the links below.
3 Replies
- suhasakoleFrequent 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.
SELECTCOUNT(DISTINCT A.emplid) AS HEADCOUNTFROMtbl_EmpHistory AS AInner join (SELECT emplid, MAX(WorkStartedDate) as WorkStartedDateFROM tbl_EmpHistoryWhere WorkStartedDate <= cast('2017-12-31' as Date) -- this data will pass as slicer from PowerBI DashboardGroup by emplid ) AS BON A.emplid = B.emplidAND A.WorkStartedDate = B.WorkStartedDateWHERElower(A.type) = 'emp'AND A.active = 1
- v-chuncz-msft
Community Support
You may take a look at the links below.
- suhasakoleFrequent Visitor
thanks