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.
Hello..
I have a finger print system..
I have 2 devices one out the door and one inside the door
if an employee want to finger print when he is out in the inside device then he must finger print when he is back in the out device
if we said the ideal case will be
Emp Name Mode Device Time
A Start\End of work Day Out 1/1/2017 8:30 AM
B Start\End of work Day Out 1/1/2017 8:35 AM
A Break IN 1/1/2017 2:00 PM
A Break Out 1/1/2017 3:00 PM
A Start\End of work Day IN 1/1/2017 5:30 PM
B Start\End of work Day IN 1/1/2017 5:35 PM
I want to find cases that are a special case.. let's assume employee B finger print for a break when he is out but he forgat to finger print it when he back again and also Employee A finger print a wrong mode when he is back of the break
Emp Name Mode Device Time
A Start\End of work Day Out 1/1/2017 8:30 AM
B Start\End of work Day Out 1/1/2017 8:35 AM
A Break IN 1/1/2017 2:00 PM
B Break IN 1/1/2017 2:00 PM
A Start\End of work Day Out 1/1/2017 3:00 PM
A Start\End of work Day IN 1/1/2017 5:30 PM
B Start\End of work Day IN 1/1/2017 5:35 PM
how can I find in DAX those cases... ?
Solved! Go to Solution.
Hi @Anonymous,
It could be done with DAX in Power BI.
1. Use the formula below to add an Index column in your table.
Index = VAR currentTime = Table1[Time] RETURN CALCULATE ( RANK.EQ ( currentTime, Table1[Time], ASC ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && DATEVALUE ( Table1[Time] ) = DATEVALUE ( EARLIER ( Table1[Time] ) ) ) )
2. Then you should be able to use the formula below to add another calculate column to flag the odd status.
Status = VAR nextMode = CALCULATE ( FIRSTNONBLANK ( Table1[Mode], 1 ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && Table1[Index] = EARLIER ( Table1[Index] ) + 1 ) ) VAR nextDevice = CALCULATE ( FIRSTNONBLANK ( Table1[Device], 1 ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && Table1[Index] = EARLIER ( Table1[Index] ) + 1 ) ) VAR preMode = CALCULATE ( FIRSTNONBLANK ( Table1[Mode], 1 ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && Table1[Index] = EARLIER ( Table1[Index] ) - 1 ) ) VAR preDevice = CALCULATE ( FIRSTNONBLANK ( Table1[Device], 1 ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && Table1[Index] = EARLIER ( Table1[Index] ) - 1 ) ) RETURN IF ( ( ( Table1[Mode] = "Break" && Table1[Device] = "IN" ) && nextDevice = "IN" ) || ( ( preMode = "Break" && preDevice = "IN" ) && ( Table1[Mode] <> "Break" && Table1[Device] = "OUT" ) ), "ODD" )
Here is the sample pbix file for your reference.
Regards
Hi @Anonymous,
It could be done with DAX in Power BI.
1. Use the formula below to add an Index column in your table.
Index = VAR currentTime = Table1[Time] RETURN CALCULATE ( RANK.EQ ( currentTime, Table1[Time], ASC ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && DATEVALUE ( Table1[Time] ) = DATEVALUE ( EARLIER ( Table1[Time] ) ) ) )
2. Then you should be able to use the formula below to add another calculate column to flag the odd status.
Status = VAR nextMode = CALCULATE ( FIRSTNONBLANK ( Table1[Mode], 1 ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && Table1[Index] = EARLIER ( Table1[Index] ) + 1 ) ) VAR nextDevice = CALCULATE ( FIRSTNONBLANK ( Table1[Device], 1 ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && Table1[Index] = EARLIER ( Table1[Index] ) + 1 ) ) VAR preMode = CALCULATE ( FIRSTNONBLANK ( Table1[Mode], 1 ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && Table1[Index] = EARLIER ( Table1[Index] ) - 1 ) ) VAR preDevice = CALCULATE ( FIRSTNONBLANK ( Table1[Device], 1 ), FILTER ( ALL ( Table1 ), Table1[Emp Name] = EARLIER ( Table1[Emp Name] ) && Table1[Index] = EARLIER ( Table1[Index] ) - 1 ) ) RETURN IF ( ( ( Table1[Mode] = "Break" && Table1[Device] = "IN" ) && nextDevice = "IN" ) || ( ( preMode = "Break" && preDevice = "IN" ) && ( Table1[Mode] <> "Break" && Table1[Device] = "OUT" ) ), "ODD" )
Here is the sample pbix file for your reference.
Regards
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
83 | |
67 | |
61 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |