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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Count Values in a table, where another column is distinct?

I currently have a table as such:

 

Foo   ID

 

True  234

False 443

False 443

True  678

 

How can I make a function that counts how many times False comes up with a unique ID? (In this example only once)

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

What is the expected output ?

 

You can create a measures

 

Measure = Count (Table[ID)  and  drag True and False Column in the visualization

 

or 

 

MEasure  = DISCTINCTCount(Table[id])

 

MEasure  = CALCULATE( DISCTINCTCount(Table[id]) , Table [foo] = "False")

 

Regards,

Harsh Nathani

 

 

 

 

View solution in original post

4 REPLIES 4
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

According to my understanding, you want to use Card visual to display the count of Foo based  on unique ID, right?

You could use the following formula:

countByID =
CALCULATE (
    COUNTROWS ( 'CountTable' ),
    FILTER (
        ALL ( CountTable ),
        'CountTable'[ID] = MAX ( 'CountTable'[ID] )
            && SELECTEDVALUE ( CountTable[Foo] ) = FALSE ()
    )
)

My visualization looks like this:

8.21.5.PNG

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

What is the expected output ?

 

You can create a measures

 

Measure = Count (Table[ID)  and  drag True and False Column in the visualization

 

or 

 

MEasure  = DISCTINCTCount(Table[id])

 

MEasure  = CALCULATE( DISCTINCTCount(Table[id]) , Table [foo] = "False")

 

Regards,

Harsh Nathani

 

 

 

 

AllisonKennedy
Super User
Super User

You can put Foo in Rows and ID in Values in a matrix visual. Then set the summarization on ID to Distinct Count by clicking the arrow next to ID.
https://docs.microsoft.com/en-us/power-bi/create-reports/service-aggregates

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

This worked! However is there any way to pull those numbers into a measure so I can insert it into a nice card visual?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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