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 have a table with elements that belong to a category. Both the element and the category are on the table viz as shown:
[Element] [Category]
a x
b y
c z
d x
e y
f y
but the categories are ranked. I mean:
[Category] [Level of importance]
x 1
y 2
z 3
What I want is to count on the first table, how many elements appear, for its category OR HIGHER. I want this:
[Element] [Category] [Count]
a x 2 (2 x's)
b y 5 (because there are 3 y's and 2 x's)
c z 6 (3 y's, 2 x's, 1 z)
d x 2
e y 5
f y 5
I hope I explained myself.
Thanks
Solved! Go to Solution.
I think this should do the trick:
Count =
var _CurrentCat = SELECTEDVALUE(ElemCat[Category])
var x =
CALCULATE(
countrows(ElemCat),
all(ElemCat),
ElemCat[Category] <= _CurrentCat
)
var result = x
return result
I think this should do the trick:
Count =
var _CurrentCat = SELECTEDVALUE(ElemCat[Category])
var x =
CALCULATE(
countrows(ElemCat),
all(ElemCat),
ElemCat[Category] <= _CurrentCat
)
var result = x
return result
Hi @jorgeslzr ,
Thanks for explaining. But it gets confusing sometime seeing x, y's and z's.
Can you share some sample data and expected output ?
Regards,
HN
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 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
8 |