Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Daniel_G
Frequent Visitor

count of items that only appear once

Hi,

 

I'm looking for a formula that will give me a number of items that appear in table only once.

I can easily do it using pivot table with a count of items = 1 filter, but I don't want a list of such items, but just a total count of them.

 

I tried to do something like X = calculate(count(vendor[No]), count(vendor[No]) = 1), but apparently I can't use count in True/False expressions.

 

Example: In a table, column 'x' I have following values: a,b,a,b,c,b,d. The result of the calculation in that case would 2 (only c and d appear once).

 

Please let me know if you know a solution for that.

 

Thank you in advance,

Daniel

 

 
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

 

Measure =
  VAR __Table =
    SUMMARIZE(
      'Table',
      [column x],
      "__Count",COUNTROWS('Table')
    )
RETURN
  COUNTROWS(FILTER(__Table,[__Count]=1))

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hello Daniel,

 

try something like

 

Measure =

VAR varTable =

    ADDCOLUMNS(

        VALUES( vendor[No] ),

        "@Count", 

        VAR varNo = vendor[No]

        VAR varFilterVendor = FILTER( vendor, vendor[No] = varNo )

        RETURN COUNTROWS( varFilterVendor )

    )

VAR varFilterTable =

    FILTER( varTable, [@Count] = 1 )

RETURN

    COUNTROWS( varFilterTable )

 

I did not test this though, so you might have to have a second look at this.

 

Regards

 

Edit: Too late, obviously.

Greg_Deckler
Super User
Super User

 

Measure =
  VAR __Table =
    SUMMARIZE(
      'Table',
      [column x],
      "__Count",COUNTROWS('Table')
    )
RETURN
  COUNTROWS(FILTER(__Table,[__Count]=1))

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg. I'm doing something similar and this code is very useful for me.


Could I ask what if I wanna add more conditions to this? So I managed to get the count of Unit IDs that appear only once by using your code. But I wanna count the ones that appear once & only if they have "pass" result. Simple data table is as below. I want the total count of it eventually. How do I get to that?

katto16_0-1668580230934.png

 

Thanks in advance!

 

Wow, that was quick 🙂

 

Thanks Greg, works like a charm!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.