Forum Discussion
Count most common string, filter based on values across tables
- 8 years ago
Hi bwyker,
Based on my test you should be able to follow steps below to get your expected result.
1. Use the formulas below to create two new calculate columns in ATTENDANCE table.
eventDiscipline = RELATED(EVENTS[eventDiscipline])
Count_of_eventDiscipline = COUNTROWS ( FILTER ( ALL ( ATTENDANCE ), ATTENDANCE[ID] = EARLIER ( ATTENDANCE[ID] ) && ATTENDANCE[eventDiscipline] = EARLIER ( ATTENDANCE[eventDiscipline] ) ) )2. Then you should be able to use the formula below to add a column to the MEMBERS table that would tell you the discipline the person attended most often and use the discipline name as the value.
MostOfenEventDiscipline = VAR maxCount = CALCULATE ( MAX ( ATTENDANCE[Count_of_eventDiscipline] ) ) RETURN CALCULATE ( FIRSTNONBLANK ( ATTENDANCE[eventDiscipline], 1 ), ATTENDANCE[Count_of_eventDiscipline] = maxCount )Here is the sample pbix file for your reference. :smileyhappy:
Regards
Hi bwyker,
Based on my test you should be able to follow steps below to get your expected result.
1. Use the formulas below to create two new calculate columns in ATTENDANCE table.
eventDiscipline = RELATED(EVENTS[eventDiscipline])
Count_of_eventDiscipline =
COUNTROWS (
FILTER (
ALL ( ATTENDANCE ),
ATTENDANCE[ID] = EARLIER ( ATTENDANCE[ID] )
&& ATTENDANCE[eventDiscipline] = EARLIER ( ATTENDANCE[eventDiscipline] )
)
)
2. Then you should be able to use the formula below to add a column to the MEMBERS table that would tell you the discipline the person attended most often and use the discipline name as the value.
MostOfenEventDiscipline =
VAR maxCount =
CALCULATE ( MAX ( ATTENDANCE[Count_of_eventDiscipline] ) )
RETURN
CALCULATE (
FIRSTNONBLANK ( ATTENDANCE[eventDiscipline], 1 ),
ATTENDANCE[Count_of_eventDiscipline] = maxCount
)
Here is the sample pbix file for your reference. :smileyhappy:
Regards
This worked perfectly! Thank you SO much for the quick response and the super efficient solution. Very much appreciated!