Extract unique value from column using DAX

Jorsch

New Member
Joined
Oct 16, 2019
Messages
1
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
AH40001
AH40002
AP99993

<tbody>
</tbody>

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?

Thanks,
Josh
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

macfuller

Active Member
Joined
Apr 30, 2014
Messages
267
Office Version
365
Platform
Windows
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?
Code:
[Permitted Index] =VAR MyIndex = MyTable[Index]
RETURN
    IF (
        CALCULATE (
            COUNTROWS ( MyTable[Row Key] ),
            FILTER ( ALL ( MyTable ), MyTable[Row Key] = EARLIER ( MyTable[Row Key] ) )
        ) > 1,
        BLANK (),
        MyIndex
    )
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:

Watch MrExcel Video

Forum statistics

Threads
1,095,172
Messages
5,442,819
Members
405,198
Latest member
Florence Thomas

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top