Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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]) )
@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])
)
Proud to be a Super User! |
|
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?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |