Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I have a question to only distinct count values that is not duplicate.
For example i have a column with "apple", "apple", "banana", "orange", and "cucumber". I want to return the value of 3 because "apple" has duplicate value.
My measure is
Count =
Var Column = 'Table'[Column]
RETURN
CALCULATE(
DISTINCTCOUNT(Column),
ALLSELECTED(Column)
)
It doesnt work for me. Thanks a lot
Solved! Go to Solution.
Hi,
Thank you for your message.
I am not sure how your desired outcome of the visualization looks like, but please check the below picture and the attached pbix file.
Count distinct only measure: =
COUNTROWS ( FILTER (DISTINCT( Data[Name] ), CALCULATE ( COUNTROWS ( Data ) ) = 1 ) )
Hi,
I am not sure how your data model looks like, but please check the below picture and the attached pbix file.
Count distinct only measure: =
COUNTROWS ( FILTER ( Data, CALCULATE ( COUNTROWS ( Data ) ) = 1 ) )
Hi Kim,
Really thanks for the pbix. I am still wondering how you can make a measure with the reference of Data (Table name) not category as the column name. I have so many columns, and i want to make measure to return a value of 3.
On my case i want the Fruit return a measure of 3 and Vegetable return value of 2 . Really thanks
Let say
| Category | Name |
| Fruit | Apple |
| Fruit | Apple |
| Fruit | Banana |
| Fruit | Orange |
| Fruit | Strawberry |
| Vegetable | Cucumber |
| Vegetable | Cauliflower |
| Vegetable | Broccoli |
| Vegetable | Broccoli |
Hi,
Thank you for your message.
I am not sure how your desired outcome of the visualization looks like, but please check the below picture and the attached pbix file.
Count distinct only measure: =
COUNTROWS ( FILTER (DISTINCT( Data[Name] ), CALCULATE ( COUNTROWS ( Data ) ) = 1 ) )
Really thanks,
It works now. Happy New Year
Hi,
Thanks for your very prompt help, although it shows no error but it produce blank row in my case.
Any idea where i might have mistaken?
Thank you so much
Hi @dannytan1112
Not sure about the current filter context but you may also try
Count =
SUMX (
ALLSELECTED ( 'Table'[Column] ),
IF ( COUNTROWS ( CALCULATETABLE ( 'Table' ) = 1, 1 )
)
you can try
Count =
SUMX (
VALUES ( 'Table'[Column] ),
IF (
COUNTROWS ( CALCULATETABLE ( 'Table' ) ) = 1,
1
)
)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 21 | |
| 12 | |
| 9 | |
| 5 | |
| 5 |