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
sjhc1177
New Member

Trouble with TOPN not working

Hi, I have a TOPN that works for listing all brands for each year. But when I try to list what has been sold for a given month and location applying the slicers to the table. The results are for all years.

 

What I would like to do is create a DAX measure that shows me the TOP 25 models sold for a specific LOCATION and MONTH. And the same type of measure but for BRANDS.

 

When I use this measure I get 30-100 results, not 25. So I must need to add something else. I've watched videos, but mabye Excel has issues with TOPn.

 

TOP 25 BRANDS UNITS SOLD:=VAR RankingContext =
VALUES ( 'tblVendor'[VENDOR NAME])
VAR TopNumber = 25
RETURN
CALCULATE (
[SALES UNITS SOLD],
TOPN ( TopNumber, ALL( 'tblVendor'[VENDOR NAME]),[SALES UNITS SOLD] ),
RankingContext
)

 

Thanks

2 REPLIES 2
Anonymous
Not applicable

"What I would like to do is create a DAX measure that shows me the TOP 25 models sold for a specific LOCATION and MONTH. And the same type of measure but for BRANDS."

 

Taking into account that a measure can only return a value, not a table, this is not possible. A DAX query (which is completely different from a measure) can return TOPN rows from a table on the other hand. So, TOPN is a feature of a filter, not of a measure.

 

Best

D.

AlB
Super User
Super User

Hi @sjhc1177 

Can you share the pbix, or a simplified version that reproduces the issue?

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.