GundayMonday
New Member
- Joined
- May 13, 2013
- Messages
- 4
Hello,
I have a weird problem and I'm not even sure if you can solve it using Power Pivot's functionality.
I'm looking at how ~500 unique IDs are changing over time within a system. The IDs can enter one of three different states within the system (let's call them A, B, and C for simplicity). Every row in my data starts with a time stamp telling what state the unique Id is in at that time. I'm trying to create a column that tells me how many times a specific ID has entered a specific state up to the current time.
So my data looks like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Timestamp[/TD]
[TD]Unique ID[/TD]
[TD]State[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]123[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]124[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]123[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]124[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]123[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]124[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]04[/TD]
[TD]123[/TD]
[TD]A[/TD]
[/TR]
</tbody>[/TABLE]
I want to return a column that counts the number of times a specific ID has newly entered each state:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Timestamp[/TD]
[TD]Unique ID[/TD]
[TD]State[/TD]
[TD]A total[/TD]
[TD]B total[/TD]
[TD]C total[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]123[/TD]
[TD]A[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]124[/TD]
[TD]B[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]123[/TD]
[TD]A[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]124[/TD]
[TD]C[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]123[/TD]
[TD]B[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]124[/TD]
[TD]B[/TD]
[TD]0[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]04[/TD]
[TD]123[/TD]
[TD]A[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]
My pseudo code would look like:
At each time stamp, check and see if the state of each ID has changed. Ignore any time stamp > than the current row.
If it has changed, add 1 to whatever the new state total is for that ID.
If it hasn't changed, keep counts from the last time step.
Is there a way to do this in PowerPivot? Excel I can do it no problem, but my data set has ~9million rows in it . I've been googling for the past few hours and trying out all these weird DAX functions, but can't find anything that works.
Can anyone help me figure this out?
I have a weird problem and I'm not even sure if you can solve it using Power Pivot's functionality.
I'm looking at how ~500 unique IDs are changing over time within a system. The IDs can enter one of three different states within the system (let's call them A, B, and C for simplicity). Every row in my data starts with a time stamp telling what state the unique Id is in at that time. I'm trying to create a column that tells me how many times a specific ID has entered a specific state up to the current time.
So my data looks like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Timestamp[/TD]
[TD]Unique ID[/TD]
[TD]State[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]123[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]124[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]123[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]124[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]123[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]124[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]04[/TD]
[TD]123[/TD]
[TD]A[/TD]
[/TR]
</tbody>[/TABLE]
I want to return a column that counts the number of times a specific ID has newly entered each state:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Timestamp[/TD]
[TD]Unique ID[/TD]
[TD]State[/TD]
[TD]A total[/TD]
[TD]B total[/TD]
[TD]C total[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]123[/TD]
[TD]A[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]124[/TD]
[TD]B[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]123[/TD]
[TD]A[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]124[/TD]
[TD]C[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]123[/TD]
[TD]B[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]124[/TD]
[TD]B[/TD]
[TD]0[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]04[/TD]
[TD]123[/TD]
[TD]A[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]
My pseudo code would look like:
At each time stamp, check and see if the state of each ID has changed. Ignore any time stamp > than the current row.
If it has changed, add 1 to whatever the new state total is for that ID.
If it hasn't changed, keep counts from the last time step.
Is there a way to do this in PowerPivot? Excel I can do it no problem, but my data set has ~9million rows in it . I've been googling for the past few hours and trying out all these weird DAX functions, but can't find anything that works.
Can anyone help me figure this out?
Last edited: