3

HOw to retrieve FIRST (N) rows while retrieving a Table from Power Pivot with Dax? What came to my mind is only to add an index column with Power Query and then to use FILTER() to enroll the SUMMARIZE()

My code:

EVALUATE
FILTER(
SUMMARIZE(
RTO_EnrolmentsAllCourses,
    RTO_EnrolmentsAllCourses[CampusName],
    RTO_EnrolmentsAllCourses[CoENo],
    RTO_EnrolmentsAllCourses[Competency],
    RTO_EnrolmentsAllCourses[Course_Finish],
    RTO_EnrolmentsAllCourses[Course_start],
    RTO_EnrolmentsAllCourses[CourseAttempt],
    RTO_EnrolmentsAllCourses[CourseID],
    RTO_EnrolmentsAllCourses[CourseName],
    RTO_EnrolmentsAllCourses[Index]
),
    RTO_EnrolmentsAllCourses[Index]<50)

Thanks in advance

Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94
Sergiy Razumov
  • 159
  • 2
  • 9

2 Answers2

3

Try this:

EVALUATE(
 SAMPLE(
  50,
  RTO_EnrolmentsAllCourses,
  RTO_EnrolmentsAllCourses[CampusName], 1,
  RTO_EnrolmentsAllCourses[CoENo], 1
 )
)

That returns the first 50 rows ordered by CampusName ascending (that's the value 1 right after CampusName) and CoENo ascending. You have to provide order by columns of you want a predictable 50 rows rather than a random 50 rows per the documentation.

GregGalloway
  • 11,355
  • 3
  • 16
  • 47
2

Thanks, GregGalloway! It is working just fine. Enrolling SAMPLE () into SUMMARIZE() I just retrieve what I needed.

EVALUATE
 SUMMARIZE(
 SAMPLE(
  10,
  RTO_EnrolmentsAllCourses,
  RTO_EnrolmentsAllCourses[CampusName], 1
 ),
 RTO_EnrolmentsAllCourses[AgentName],
 RTO_EnrolmentsAllCourses[CampusName]
 )

Thanks again!

Sergiy Razumov
  • 159
  • 2
  • 9