The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I am very new to PowerBI and I have a scenario where only certain employees are given access to a specific area. If another employee without access rights swipes his/her card, an error is generated as "Swipe access violation". I want to check if any specific employee (without access rights) has been swiping his/her card continuously for 3 days or more.
List of Data fields - Employee ID, Swipe Date & Time and Error Description
I have created a table in PowerBI with Employee ID and Date in Row field and and a measure.
Measure = CALCULATE([Error Count],DATEADD('Calendar'[Date],-3,DAY))
The above measure is only showing me the number of errors which has happened 3 days before but not the summation of the errors over the last 3 days.
Request help on this issue.
Solved! Go to Solution.
@ssray wrote:
I am very new to PowerBI and I have a scenario where only certain employees are given access to a specific area. If another employee without access rights swipes his/her card, an error is generated as "Swipe access violation". I want to check if any specific employee (without access rights) has been swiping his/her card continuously for 3 days or more.
List of Data fields - Employee ID, Swipe Date & Time and Error Description
I have created a table in PowerBI with Employee ID and Date in Row field and and a measure.
Measure = CALCULATE([Error Count],DATEADD('Calendar'[Date],-3,DAY))
The above measure is only showing me the number of errors which has happened 3 days before but not the summation of the errors over the last 3 days.
Request help on this issue.
Based on my understanding, you could try a measure as below.
The logic is,
isContinuous3daysViolateAccessOverLast3days = VAR Overlast3ErrorHistory = TOPN ( 3, DISTINCT ( SELECTCOLUMNS ( FILTER ( yourTable, yourTable[Error Description] = "Swipe access violation" ), "Employee ID", yourTable[Employee ID], "Swipe date", yourTable[Swipe Date & Time] ) ), [Swipe date], DESC ) RETURN IF ( COUNTROWS ( Overlast3ErrorHistory ) = 3 && MAXX ( Overlast3ErrorHistory, [Swipe date] ) = MAX ( yourTable[Swipe Date & Time] ) && MAXX ( Overlast3ErrorHistory, [Swipe date] ) - MINX ( Overlast3ErrorHistory, [Swipe date] ) = 2, "Yes", "No" )
See the attached pbix file. If it is not your case, please provide some sample data and expected output. Even better, you can upload the pbix file. Please upload the pbix file to Onedrive or any web storage and share the link. Do remember to mask sensitive data before uploading.
@ssray wrote:
I am very new to PowerBI and I have a scenario where only certain employees are given access to a specific area. If another employee without access rights swipes his/her card, an error is generated as "Swipe access violation". I want to check if any specific employee (without access rights) has been swiping his/her card continuously for 3 days or more.
List of Data fields - Employee ID, Swipe Date & Time and Error Description
I have created a table in PowerBI with Employee ID and Date in Row field and and a measure.
Measure = CALCULATE([Error Count],DATEADD('Calendar'[Date],-3,DAY))
The above measure is only showing me the number of errors which has happened 3 days before but not the summation of the errors over the last 3 days.
Request help on this issue.
Based on my understanding, you could try a measure as below.
The logic is,
isContinuous3daysViolateAccessOverLast3days = VAR Overlast3ErrorHistory = TOPN ( 3, DISTINCT ( SELECTCOLUMNS ( FILTER ( yourTable, yourTable[Error Description] = "Swipe access violation" ), "Employee ID", yourTable[Employee ID], "Swipe date", yourTable[Swipe Date & Time] ) ), [Swipe date], DESC ) RETURN IF ( COUNTROWS ( Overlast3ErrorHistory ) = 3 && MAXX ( Overlast3ErrorHistory, [Swipe date] ) = MAX ( yourTable[Swipe Date & Time] ) && MAXX ( Overlast3ErrorHistory, [Swipe date] ) - MINX ( Overlast3ErrorHistory, [Swipe date] ) = 2, "Yes", "No" )
See the attached pbix file. If it is not your case, please provide some sample data and expected output. Even better, you can upload the pbix file. Please upload the pbix file to Onedrive or any web storage and share the link. Do remember to mask sensitive data before uploading.