Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Countif in DAX or Power Query

Hi all,   Please help as i was not able to find solution for what i require. I have dataset with repeating ID number and i need to count how many times it repeats in a dataset. Groupby does not wo...
  • Cmcmahan's avatar
    Cmcmahan
    7 years ago

    If all you need is a measure for a card that displays the count of IDs that appear 2+ times, that should be pretty easy.  I'm not sure why you're so against using summarization or groupings for a single measure, but here's how I would do it:

    CountMultiIDs = COUNTROWS(FILTER(ADDCOLUMNS( VALUES('Table'[ID]), "IDCount", CALCULATE(COUNTROWS('Table'))), [IDCount]>1))

    The tricky bit here is to use CALCULATE around the inner COUNTROWS so that the DAX re-evaluates the context at which it is counting.