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
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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:
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,913
Members
448,532
Latest member
9Kimo3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top