Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
Hello.
I have a table with these fields:
- employee: ID number of the worker
- location: "home" or "office"
- date: each day the employee worked
I need to count how many changes from "home" to "office" or "office" to "home" had each employee. Of course, each change should be coherent in time. For example, for one employee:
| date | Location |
| 25/09 | home |
| 26/09 | office |
| 27/09 | home |
| 28/09 | home |
| 29/09 | home |
the count should be 2. How can I do that? I may also need to detail only the changes. Which is the best approach? A new column with M? A new table? I discard the measure, because of that need of the detailed info of only the changes.
Thanks,
Solved! Go to Solution.
Hi @grojnak ,
I suggest you to try code as below to create a measure.
My Sample:
Count Location Change For Employee =
VAR _SUMMARIZE =
SUMMARIZE (
ADDCOLUMNS (
'Table',
"CheckPoint",
CALCULATE (
MIN ( 'Table'[date] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Employee ID] ),
'Table'[date] > EARLIER ( [date] )
&& 'Table'[Location] <> EARLIER ( [Location] )
)
)
),
[Employee ID],
[CheckPoint]
)
RETURN
COUNTX ( _SUMMARIZE, [CheckPoint] )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @grojnak ,
I suggest you to try code as below to create a measure.
My Sample:
Count Location Change For Employee =
VAR _SUMMARIZE =
SUMMARIZE (
ADDCOLUMNS (
'Table',
"CheckPoint",
CALCULATE (
MIN ( 'Table'[date] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Employee ID] ),
'Table'[date] > EARLIER ( [date] )
&& 'Table'[Location] <> EARLIER ( [Location] )
)
)
),
[Employee ID],
[CheckPoint]
)
RETURN
COUNTX ( _SUMMARIZE, [CheckPoint] )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Yes, this can easily be done in Power Query via grouping. Read about GroupKind.Local
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |