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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Distinct function shows wrong result

Hi Guys,

 

I have some issue with results on powerBI differing from DB. I have a query like this on DB:

 

  SELECT DISTINCT(Sale_SK), DATE
  FROM [dbo].[table_sales]
  WHERE status='sold'  AND Date>'2018-01-01 00:00:00.000'

 

Sale_SK is an ID and can be repeated.

 

That's return the number 423.

 

I do a measure in powerBI like Sales = DISTINCTCOUNT(table_sales[Sale_SK]) to see this number, and I add two slicers with Year (Calendar table linked to mi column Date in a relation) and "Status".

 

So the problem is when I select Year=2018 and Status=sold. That's returning me 394.

 

394 is the same if I do this SELECT (without Date Column) on SQL_DB:

 

  SELECT DISTINCT(Sale_SK)
  FROM [dbo].[table_sales]
  WHERE status='sold'

 

Anyone knows how can I do to see the correct result like 423 filtering or doing a measure correctly in both with date?

 

Thank you very much in advance.

 

 

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may use measure below.

Measure =
COUNTROWS ( SUMMARIZE ( table_sales, table_sales[Sale_SK], table_sales[Date] ) )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may use measure below.

Measure =
COUNTROWS ( SUMMARIZE ( table_sales, table_sales[Sale_SK], table_sales[Date] ) )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.