Forum Discussion
SBR1D
Helper III
2 years agoCountRows problem
Hi Everyone Below is a simplified version of my actual table. I have a slicer where a user can select an Employer name ( A,B,C,D), when they choose an employer I want to get a count of all of...
- 2 years ago
The original formula takes into account that you might select more than one value which, in this case, SELECTEDVALUE will not work. If you want just a single selection:
Number of Parent IDs = VAR __PARENT_ID = CALCULATE ( MAX ( 'Table'[ParentEmployerID] ), ALLSELECTED ( 'Table' ) ) RETURN CALCULATE ( COUNTROWS ( 'Learning Plan' ), 'Learning Plan'[ParentID] = __PARENT_ID, USERELATIONSHIP ( 'Learning Plan'[EmployerId], Employer[EmployerId] ) )
danextian
Super User
2 years agoHi SBR1D
With just the data provided, here's a sample formula:
Number of Parent IDs =
VAR __PARENT_ID =
SUMMARIZE (
CALCULATETABLE (
'Table',
'Table'[Employer] IN VALUES ( 'Table'[Employer] ),
REMOVEFILTERS ()
),
'Table'[ParentEmployerID]
)
RETURN
CALCULATE (
COUNTROWS ( 'Learning Plan' ),
'Learning Plan'[ParentID] IN __PARENT_ID,
USERELATIONSHIP ( 'Learning Plan'[EmployerId], Employer[EmployerId] )
)
Otherwise, please provide a sanitized copy of your pbix.
- SBR1D2 years ago
Helper III
That looks good but what about the selected value part please?
- danextian2 years ago
Super User
The original formula takes into account that you might select more than one value which, in this case, SELECTEDVALUE will not work. If you want just a single selection:
Number of Parent IDs = VAR __PARENT_ID = CALCULATE ( MAX ( 'Table'[ParentEmployerID] ), ALLSELECTED ( 'Table' ) ) RETURN CALCULATE ( COUNTROWS ( 'Learning Plan' ), 'Learning Plan'[ParentID] = __PARENT_ID, USERELATIONSHIP ( 'Learning Plan'[EmployerId], Employer[EmployerId] ) )