Extract unique value from column using DAX


New Member
I've come across what I thought should be a simple problem, but I can't quite figure it out. I have a table that's the result of an expression that could have a column like this in certain instances:

Row Key Index


What I want is to keep only rows with a unique row key so that I can get the correct single index value (the red value). Using distinct/values wouldn't help because it would still show the 1st or 2nd row in the table, where as I want those rows that contain a row key that exists in the table more than once to be fully excluded. I can't rely on position of the index because it varies, so I don't think min/max would work. I have this calculation as part of a complicated calculated column so there are memory concerns as well. Is there an easy answer to this that I'm missing?



Board Regular
If I understand your question, you want your filter to exclude all rows where the row key appears more than once and to capture the index value. What about a COUNTROWS?
[Permitted Index] =VAR MyIndex = MyTable[Index]
    IF (
        CALCULATE (
            COUNTROWS ( MyTable[Row Key] ),
            FILTER ( ALL ( MyTable ), MyTable[Row Key] = EARLIER ( MyTable[Row Key] ) )
        ) > 1,
        BLANK (),
Shame on me, I can't remember if the countrows returns the original row too (I think so). If not, you would have to set the test to > 0.
Last edited:

Some videos you may like

This Week's Hot Topics

  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • find many based on a certain criteria
    good evening, I hope someone can help me? I have a workbook sheet 2 contains lots of data.... I would like to be able to find anything on sheet...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
  • Text Format
    I have a sheet for user to keyin the data. The format of the data can be 451 / 1903, 0012 / 9908 or 00287 / 0099. The number after the "/" is...
  • Syntax errors
    Good Morning, Trying to compile a workbook, I keep getting a few errors. Here are the first two: [code=rich]Syntax Error: Function...