Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Silvard
Resolver I
Resolver I

Using inscope and filtering rows

I'm trying to create a measure that can be used in a graph (x-axis) where the y-axis consists of three levels of hierarchy.

 

At the two top levels I'd like to use distinctcount for JobID (key) for all rows, but at the lowest levels, I'd like to use distinctcount for ApplicationID (key) for some rows and for the rest JobID.

 

I have tried below, but it only seems to be using JobID. 

 

Your help is much appreciated!

 

DistinctCountByHierarchy =

VAR IsAtLowestLevel = ISINSCOPE('Table'[HierarchyColumn])

VAR = TargetHierarchyValues = {10, 11, 12, 13, 14, 15}

VAR IsTargetHierarchyInScope = IF( IsAtLowestLevel, COUNTROWS( FILTER( ALL('Table'), 'Table'[HierarchyColumn] IN TargetHierarchyValues ) ) > 0, FALSE )

RETURN

IF( IsTargetHierarchyInScope, CALCULATE( DISTINCTCOUNT('Table'[ApplicationID]), 'Table'[HierarchyColumn] IN TargetHierarchyValues ), DISTINCTCOUNT('Table'[JobID]) )

2 REPLIES 2
bhanu_gautam
Super User
Super User

@Silvard , Try using below measure

 

DistinctCountByHierarchy =
VAR IsAtLowestLevel = ISINSCOPE('Table'[HierarchyColumn])
VAR TargetHierarchyValues = {10, 11, 12, 13, 14, 15}
VAR IsTargetHierarchyInScope = IF(
IsAtLowestLevel,
COUNTROWS(
FILTER(
ALL('Table'),
'Table'[HierarchyColumn] IN TargetHierarchyValues
)
) > 0,
FALSE
)
RETURN
IF(
IsAtLowestLevel,
IF(
IsTargetHierarchyInScope,
CALCULATE(
DISTINCTCOUNT('Table'[ApplicationID]),
'Table'[HierarchyColumn] IN TargetHierarchyValues
),
DISTINCTCOUNT('Table'[JobID])
),
DISTINCTCOUNT('Table'[JobID])
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi @bhanu_gautam 

 

Thanks so much for asssiting but unfortunately it produces the same result.

 

have you got any other suggestions or perhaps we need to be using another method?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.