Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rpinxt
Impactful Individual
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:
rpinxt_0-1665754058396.png

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

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é
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

View solution in original post

6 REPLIES 6
jcalheir
Solution Supplier
Solution Supplier

Hi

 

Do this

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

 

 Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

rpinxt
Impactful Individual
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:
rpinxt_0-1665755320490.png

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

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

rpinxt
Impactful Individual
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:

https://drive.google.com/file/d/1wGjxsuFgUAG-q1CgvvEMfSy4zGzjy-Nc/view?usp=drivesdk

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é
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

rpinxt
Impactful Individual
Impactful Individual

Thanks @jcalheir  this works fine 😁

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.