cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Impactful Individual

## TopN in Dax not working

Trying to make a (I thought) simple TopN measure like :

Top5_BO_Qty = TOPN(5,'Backorder Details',[BO Qty],DESC)

But getting this error:

Anybody that can help me out and tell me whats wrong and how to fix?

I want the Top 5 on field PF name (it will not let me choose that field only the table Backorder details) based on BO Qty.

1 ACCEPTED SOLUTION
Solution Supplier

Sorry, i was just looking at the function and forgot to calculate the measure.

This works

``````Top5_BO_Qty =
CALCULATE(
[BO Qty],
KEEPFILTERS(
TOPN(
5,
ALL('Backorder Details'[PF Name]),
[BO Qty],
DESC
)
)
)``````

Kind regards,
José

6 REPLIES 6
Solution Supplier

Hi

Do this

``````Top5_BO_Qty =
TOPN(5,
ALL('Backorder Details'[yourfield]),
[BO Qty],
DESC)``````

Kind regards,
José

Impactful Individual

Thanks @jcalheir
Did this :

Top5_BO_Qty = TOPN(5,
ALL('Backorder Details'[PF Name]),
[BO Qty],
DESC)
** How did you get that grey box around your code?

But still no luck:

It is a card, so just to check the one value measure.

Solution Supplier

Is it possible to share your PBIX file so we can take a look?

Impactful Individual

Ok had to throw out a lot because it work data, but still the field from the measure are there and also the error.

So hopefully this example is enough to solve it.

I cannot add a file here so I put it on drive:

Solution Supplier

Sorry, i was just looking at the function and forgot to calculate the measure.

This works

``````Top5_BO_Qty =
CALCULATE(
[BO Qty],
KEEPFILTERS(
TOPN(
5,
ALL('Backorder Details'[PF Name]),
[BO Qty],
DESC
)
)
)``````

Kind regards,
José

Impactful Individual

Thanks @jcalheir  this works fine 😁

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors