Forum Discussion
Counting instances
- 3 years ago
Hi,
Please check the below picture and the attached pbix file.
Total count CC = COUNTROWS ( FILTER ( Data, Data[UNID] = EARLIER ( Data[UNID] ) && Data[From Date] <= EARLIER ( Data[From Date] ) ) )In year count CC = COUNTROWS ( FILTER ( Data, Data[UNID] = EARLIER ( Data[UNID] ) && YEAR ( Data[From Date] ) = YEAR ( EARLIER ( Data[From Date] ) ) && Data[From Date] <= EARLIER ( Data[From Date] ) ) ) - 3 years ago
Hi,
Thank you for your reply.
I am not sure if I correctly understood your second questions, but please check the below picture and the attached pbix file whether it suits your requirement.
Expected CC = VAR _toponebyyeartable = TOPN ( 1, FILTER ( Data, Data[UNID] = EARLIER ( Data[UNID] ) && YEAR ( Data[From Date] ) = YEAR ( EARLIER ( Data[From Date] ) ) ), Data[In year count CC], DESC ) RETURN IF ( MAXX ( _toponebyyeartable, Data[In year count CC] ) = Data[In year count CC], Data[In year count CC] )
Jihwan_Kim This is perfect thank you.
So the next step - Is there a way that just the most recent instance in each year is marked?
I.e for those that have just 1 instance in a year we get a 1, for those that have had 2 instances in a year the first instance in blank and the second is mark as 2 and so on?
When I count this the 1 is throwing the figures off a little as someone with 2 or more instances is also appearing in the column counting their first and second instance as well.
Hi,
Thank you for your reply.
I am not sure if I correctly understood your second questions, but please check the below picture and the attached pbix file whether it suits your requirement.
Expected CC =
VAR _toponebyyeartable =
TOPN (
1,
FILTER (
Data,
Data[UNID] = EARLIER ( Data[UNID] )
&& YEAR ( Data[From Date] ) = YEAR ( EARLIER ( Data[From Date] ) )
),
Data[In year count CC], DESC
)
RETURN
IF (
MAXX ( _toponebyyeartable, Data[In year count CC] ) = Data[In year count CC],
Data[In year count CC]
)
- EWBWEBB3 years agoHelper III
Spoth on Jihwan_Kim - thank you so much