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
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
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.