1
votes

I'm trying to find the Nth selected item from a list of text values that are used in a filter. I cannot find a good solution that will do this. Below is what I currently have (in DAX Studio)

//First get all of the Selected Scenarios and then Rank them based on alphabetical names
//Then filter the Rank to the specific one that I want

Define
var Scenarios = 
Filter(
    AddColumns(ALLSELECTED('Financial All Scenarios'[Scenario]),
    "Rank", RANKX(
        ALLSELECTED('Financial All Scenarios'[Scenario]), 
        'Financial All Scenarios'[Scenario], 
        , 
        ASC
    )
), 
[Rank] = 2)

//Return just the Scenario value for the row that is returned above.
EVALUATE(

MinX(Scenarios, [Scenario])
//Scenarios
)

The above gives me the error of the expression specified in the query is not a valid table expression.

I'm note sure why or of another way to get this to work.

1

1 Answers

1
votes

Probably this below measure will give you the expected output-

nth_scenario = 

MAXX(
    TOPN(
        2,
        ALLSELECTED('Financial All Scenarios'),        
        'Financial All Scenarios'[Scenario], 
        ASC
    ),
    'Financial All Scenarios'[Scenario]
)