cancel
Showing results for
Did you mean:
Highlighted
Regular Visitor

## RANKX Measure issue

The problem is that I have a top 10 measure with rankx:

```Top Clientes =
VAR
Prod = [Mas Vendido]
VAR
Cliente = VALUES(Clientes[CompanyName])
RETURN
CALCULATE([Ventas Total];
FILTER(Cliente;
RANKX(ALL(Clientes[CompanyName]); [Ventas Total];;DESC) <= 10); Productos[ProductName] = Prod)```

And when I select an specific year it should only show me the top 10 customers who bought the top product, in this case Okkaba Skin Jackets, but if you see in the second image only 3 customers buy it that year, therefore in the table of the first image should only be 3 customers not 10, how can I fix this?

PSD: Here's the code for "Mas Vendido" if you need it:

`Mas Vendido = FIRSTNONBLANK(TOPN(1; ALL(Productos[ProductName]);[Ventas Total];DESC); 1)`
1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

## Re: RANKX Measure issue

@amilkarigi

HI, I try to simplify this:

```Top Clientesrl =
VAR Prod = [Mas Vendido]
RETURN
CALCULATE ( [Ventas Total]; Ordenes[ProductName] = Prod )```

in the visual level filter

regards

Victor

Lima - Peru

Proud to be a Datanaut!

12 REPLIES 12
Community Support Team

## Re: RANKX Measure issue

You may try to use ALLSELECTED Function.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regular Visitor

## Re: RANKX Measure issue

In which measure? Top Clientes?

Super User

## Re: RANKX Measure issue

Hi,

My suggestion is to create a seperate RANK measure

=RANKX(ALL(Clientes[CompanyName]); [Ventas Total];;DESC)

Now in the first visual, drag this measure to the Visual Level filters and apply a criteria there of <=10.

Regular Visitor

Super User

## Re: RANKX Measure issue

Hi,

I checked another post as well where you have described the same/similar problem.  Sorry but i cannot help much since the language there is no English.  Also, the link that you have shared in your previous post does not work.

Regular Visitor

## Re: RANKX Measure issue

Super Contributor

## Re: RANKX Measure issue

@amilkarigi

hi, Edit this measure:

```Mas Vendido =
CALCULATE (
FIRSTNONBLANK ( TOPN ( 1; ALL ( Productos[ProductName] ); [ProdV]; DESC ); 1 );
ALL ( Clientes[CompanyName] )
)```

Regards

Victor

Lima -Peru

Lima - Peru

Proud to be a Datanaut!

Regular Visitor

## Re: RANKX Measure issue

Thanks @Vvelarde but it doesn't work, because if I select 2013 it just give me 3 companies, when it should give me 6, in this order:

ResultExpected result

The idea is that the result should be the top 10 companies that have bought my "mas vendido" (top product). In this example the Halter Dress has had 0 sales along with other products, but in 2013 was the top buyed product from this group with almost 91K sales.

Super Contributor

## Re: RANKX Measure issue

@amilkarigi

HI, I try to simplify this:

```Top Clientesrl =
VAR Prod = [Mas Vendido]
RETURN
CALCULATE ( [Ventas Total]; Ordenes[ProductName] = Prod )```

in the visual level filter

regards

Victor

Lima - Peru

Proud to be a Datanaut!

Announcements

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 126 members 1,402 guests
Recent signins: