Forum Discussion
Help with a running count by category
Hi,
I have the following data, Type and Result. I'd like to create a running count of each instance of "Type", starting anew with a new Type, such as in my column "Desired Running Count". I've tried so many different ideas I think I'm missing the forest for the trees.
Can anyone help?
JGiesy349 , You can create a measure for this
Desired Running Count =
VAR CurrentType = Data[Type]
VAR CurrentRow = EARLIER(Data)
RETURN
COUNTROWS(
FILTER(
Data,
Data[Type] = CurrentType &&
Data[Index] <= CurrentRow[Index]
)
)
2 Replies
- bhanu_gautam
Super User
JGiesy349 , You can create a measure for this
Desired Running Count =
VAR CurrentType = Data[Type]
VAR CurrentRow = EARLIER(Data)
RETURN
COUNTROWS(
FILTER(
Data,
Data[Type] = CurrentType &&
Data[Index] <= CurrentRow[Index]
)
)- JGiesy349New Member
Thank you very much bhanu_gautam !
I modified it slightly to get it to work, but it did.
Desired Running Count =VAR CurrentType = Data[Type]RETURNCOUNTROWS(FILTER(Data,Data[Type] = CurrentType &&Data[Index] <= EARLIER(Data[Index])))