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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
MIkkelHyldig
Helper II
Helper II

Remove TOPN from query

Hi guys,

For Power Automate I need to run a query for a table and therefore I copy my query from performance analyzer in Power BI from the table I need. 

However, instead of returning the entire table data it only queries the top 501. 

How do I just query the entire table / remove TopN? My desired result should be around 83000 rows 

// DAX Query
DEFINE
  VAR __DS0Core = 
    SUMMARIZE(
      'Activity',
      'Activity'[Activity],
      'Activity'[CapacityName],
      'Activity'[LastRefreshTime],
      'Activity'[Report_BK],
      'Activity'[User_BK],
      'Activity'[Date_Creation_BK],
      'Activity'[Dataset_BK],
      'Activity'[Group_BK],
      'Activity'[Time_Creation_BK]
    )

  VAR __DS0PrimaryWindowed = 
    TOPN(
      501,
      __DS0Core,
      'Activity'[Activity],
      1,
      'Activity'[CapacityName],
      1,
      'Activity'[LastRefreshTime],
      1,
      'Activity'[Report_BK],
      1,
      'Activity'[User_BK],
      1,
      'Activity'[Date_Creation_BK],
      1,
      'Activity'[Dataset_BK],
      1,
      'Activity'[Group_BK],
      1,
      'Activity'[Time_Creation_BK],
      1
    )

EVALUATE
  __DS0PrimaryWindowed

ORDER BY
  'Activity'[Activity],
  'Activity'[CapacityName],
  'Activity'[LastRefreshTime],
  'Activity'[Report_BK],
  'Activity'[User_BK],
  'Activity'[Date_Creation_BK],
  'Activity'[Dataset_BK],
  'Activity'[Group_BK],
  'Activity'[Time_Creation_BK]


Thanks a lot,

Mikkel

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MIkkelHyldig , Try like

 

// DAX Query
DEFINE
VAR __DS0Core =
SUMMARIZE(
'Activity',
'Activity'[Activity],
'Activity'[CapacityName],
'Activity'[LastRefreshTime],
'Activity'[Report_BK],
'Activity'[User_BK],
'Activity'[Date_Creation_BK],
'Activity'[Dataset_BK],
'Activity'[Group_BK],
'Activity'[Time_Creation_BK]
)


EVALUATE
__DS0Core

ORDER BY
'Activity'[Activity],
'Activity'[CapacityName],
'Activity'[LastRefreshTime],
'Activity'[Report_BK],
'Activity'[User_BK],
'Activity'[Date_Creation_BK],
'Activity'[Dataset_BK],
'Activity'[Group_BK],
'Activity'[Time_Creation_BK]

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@MIkkelHyldig , Try like

 

// DAX Query
DEFINE
VAR __DS0Core =
SUMMARIZE(
'Activity',
'Activity'[Activity],
'Activity'[CapacityName],
'Activity'[LastRefreshTime],
'Activity'[Report_BK],
'Activity'[User_BK],
'Activity'[Date_Creation_BK],
'Activity'[Dataset_BK],
'Activity'[Group_BK],
'Activity'[Time_Creation_BK]
)


EVALUATE
__DS0Core

ORDER BY
'Activity'[Activity],
'Activity'[CapacityName],
'Activity'[LastRefreshTime],
'Activity'[Report_BK],
'Activity'[User_BK],
'Activity'[Date_Creation_BK],
'Activity'[Dataset_BK],
'Activity'[Group_BK],
'Activity'[Time_Creation_BK]

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak ,

It worked. I tried to remove the variable "TopN" and the ORDER BY but got an error. Is the solution to keep the ORDER BY function?

Yes, I believe you need to keep the Order By function. 

 

I had a similar query and removed the TOPN function, the only issue I have is that the query will only extract 10,000 rows. Unfortunately my query needs 1,000,000+ rows. 

 

Does anyone have any solutions? 

Old, but in case anyone is here looking for answers. You can just drop these queries into PowerBI Report builder to quickly and easily write the DAX for a Paginated Report. No row limit then.

@AlLangstaff what does this mean?


@AlLangstaff wrote:

Old, but in case anyone is here looking for answers. You can just drop these queries into PowerBI Report builder to quickly and easily write the DAX for a Paginated Report. No row limit then.


Drop from where?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors