ExecuteFilterOrderedRows()

Executes a data filter and returns an ordered rowset that contains the results.

This function only works with data filters that are based on data extensions. You can’t use this function with data filters that are based on profile attributes.

Use this function only on CloudPages, landing pages, microsites, and SMS messages created in MobileConnect.

The ExecuteFilterOrderedRows() function has three parameters:

  • dataFilterExternalId (string): Required. The external ID of the data filter to execute. This function only works with data filters that are based on data extensions.
  • numRows (number): Required. The number of rows to return in the rowset. A value of 0 returns all results. There’s no maximum number of rows that can be returned.
  • sortColumn (string): Required. The column to sort data by, followed by a space and either "ASC" (for ascending order) or "DESC" (descending).

This example uses a data extension called "MembershipRewardsProgramme," which contains the data in this table.

MemberIdFirstNameSurnameRewardsPointsRewardsTierArea
1DennisSmithers923742Chelsea
2PoojaChatterjee2010421Hammersmith
3TomásSantos693113Kensington
4Sun-HiKim239994Twickenham
5JianYeh151234Chelsea

The account also contains a data filter called "MembershipRewardsProgramme_50k points plus," with an external key of c5a7e0d9-41e0-4068-bdcc-8766d7c1af94. This data filter searches for all values in which the number in the RewardsPoints column is greater than or equal to 50000.

This code example filters the data extension based on the data filter and sorts the results in descending order based on the values in the RewardsPoints column.

The code example returns a table that contains values from the rowset.

RankMemberIdFirstNameSurnameRewardsPointsArea
12PoojaChatterjee201042Hammersmith
21DennisSmithers92374Chelsea
33TomásSantos69311Kensington