Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello everyone,
I am having a bit of trouble with to referencing the top ranking Sales Category. I have created a measure which produces the ranking of categories based off sales:
I want to create a measure which will tell us what is the top ranking Category (SALOON AND CAB), and another measure which shows the Sales Amount for that Category.
Any tips?
Solved! Go to Solution.
HI @Anonymous
Try these measures
Category Top =
VAR _A =
FILTER (
ADDCOLUMNS (
'Sales',
"Rank",
RANKX (
ALLSELECTED ( 'Sales'[Category] ),
CALCULATE ( SUM ( 'Sales'[Sales Amount] ) ),
,
DESC,
DENSE
)
),
[Rank] = 1
)
RETURN
MAXX ( _A, [Category] )
and
Sales Amount Top =
VAR _A =
FILTER (
ADDCOLUMNS (
'Sales',
"Rank",
RANKX (
ALLSELECTED ( 'Sales'[Category] ),
CALCULATE ( SUM ( 'Sales'[Sales Amount] ) ),
,
DESC,
DENSE
)
),
[Rank] = 1
)
RETURN
SUMX( _A, [Sales Amount] )
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hi @Anonymous
You are welcome.
Change that ALLSELECTED ( 'Sales'[Category] ) to 'Sales' and check it then.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hello VahidDM,
Thank you for solving this.
Quick question, I am trying to filter the ranking for a certain period (say within the last 7 days). To do this, I am replacing your line of:
CALCULATE ( SUM ( 'Sales'[Sales Amount] ))
with
CALCULATE ( SUM ( 'Sales'[Sales Amount] ), DATESINPERIOD('Sales'[DATE], TODAY(), -7, DAY)
The previously mentioned [RankSales] still shows 'Saloon and Cab' as the top rank but the measure doesn't seem to update the category as 'Saloon and Cab'.
Any thoughts?
Thanks again for your time and efforts.
Any thoughts? Thank you for your time and efforts.
Hi @Anonymous
You are welcome.
Change that ALLSELECTED ( 'Sales'[Category] ) to 'Sales' and check it then.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
HI @Anonymous
Try these measures
Category Top =
VAR _A =
FILTER (
ADDCOLUMNS (
'Sales',
"Rank",
RANKX (
ALLSELECTED ( 'Sales'[Category] ),
CALCULATE ( SUM ( 'Sales'[Sales Amount] ) ),
,
DESC,
DENSE
)
),
[Rank] = 1
)
RETURN
MAXX ( _A, [Category] )
and
Sales Amount Top =
VAR _A =
FILTER (
ADDCOLUMNS (
'Sales',
"Rank",
RANKX (
ALLSELECTED ( 'Sales'[Category] ),
CALCULATE ( SUM ( 'Sales'[Sales Amount] ) ),
,
DESC,
DENSE
)
),
[Rank] = 1
)
RETURN
SUMX( _A, [Sales Amount] )
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
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 |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |