1

I wrote a DAX query that include some different kind of measure in SSAS Tabular model. Now I have to break my solution in some pages for using in application and sort by my measures.

I used TOPNSKIP() function but can not creating table that sorted by measure.

DAX code:

EVALUATE 
SELECTCOLUMNS(
      TopnSkip ( 5,0,'Station',Station[StationTitle],asc),
        "NameOfStation",Station[StationTitle],
        "TradeSellPrice", [TradeSellPrice],
        "TradePrice" ,[TradePrice],
        BrokerCommission",[BrokerCommission])
    Order by [TradePrice] asc

This code first select Top 5 from "Station" table and then sorted by "Tradeprice". This is not my expectation and what I need a solution sorted by "TradePrice".

1 Answers1

0
EVALUATE
TOPNSKIP (
  5, 0,
  SELECTCOLUMNS (
    'Station',
    "NameOfStation", 'Station'[StationTitle],
    "TradeSellPrice", [TradeSellPrice],
    "TradePrice", [TradePrice],
    "BrokerCommission", [BrokerCommission]
  ),
  [TradePrice],
  ASC
)
ORDER BY [TradePrice] ASC

First arg to SELECTCOLUMNS is a table. You passed it the table TOPNSKIP ( 5, 0, 'Station', 'Station'[StationTitle], ASC ), which is the 5-row table of the first five StationTitles.

Then, you defined the columns to select from that 5-row table. And finally you ordered the output of that table by [TradePrice].

TOPNSKIP takes a table as input. So pass it the table with the columns you need to define, and sort by any of them.

greggyb
  • 3,728
  • 1
  • 11
  • 32