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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ACUNILIN
Regular Visitor

TOP N DAX Error

Hello,

 

I am trying to do a TOP N to find the most common leadtimes for our cutomers. 

 

Here is the formula I have written.

ACUNILIN_0-1605866535471.png

But I get the following error message on the visual

 

ACUNILIN_1-1605866586446.png

 

I don't see how it's looking at multiple columns. The requested to confrimed leadtime column is a calculated column that takes the date diff of requested delivery date and confirmed delivery date.

 

I have tried changing the formula to use actual delivered quantity to see if this got rid of the multiple columns message, as this comes straight from the query but the error message was the same.

 

Can anyone help?

 

 

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @ACUNILIN ,

TOPN()  returns the top N rows of the specified table, you can not use it directly in the formula, it uses as a 'filter' in the formula, for example:

Measure = 
CALCULATE(
    SUM('Table'[Value]),
    TOPN(
        5,
        ALL('Table'),
        'Table'[Value],ASC
    )
)

topN.png

You need to use the TopN() function with other calculation formulas at the same time.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @ACUNILIN ,

TOPN()  returns the top N rows of the specified table, you can not use it directly in the formula, it uses as a 'filter' in the formula, for example:

Measure = 
CALCULATE(
    SUM('Table'[Value]),
    TOPN(
        5,
        ALL('Table'),
        'Table'[Value],ASC
    )
)

topN.png

You need to use the TopN() function with other calculation formulas at the same time.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@ACUNILIN , Refer to my video, I  have discussed how to use TOPN

https://youtu.be/QIVEFp-QiOk

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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