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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gluizqueiroz
Resolver I
Resolver I

Reasons to simple CALCULATE with DISTINCTCOUNT and FILTER doesn't working correctly on card

I have a table with sales, normal table (Customer_Id, Customer_Name and Sale_Value).

I have been trying to create a simple measure that returns me the DISTINCTCOUNT of Customers that bought more than $1000, just this. 

MeasureWithProblem = CALCULATE(DISTINCTCOUNT(Table[Customer_Id]); FILTER(Table; SUM(Table[Sale_Value]) > 1000))


If I put on a visual table the following columns: Customer_Id, Customer_Name, Sale_Value, MeasureWithProblem), I have the followin results:

Customer_IDCustomer_NameSale_Value(sum)MeasureWithProblem
1Jonh Doe115331
2Jonh Doe74761
3Finn23381
4Poe18241
5Ren332 


So far it's good, but if I put the same "MeasureWithProblem" on a card, I have the number "5".

My problem is: Why I have the number if I don't have 5 customers with more than 1000 of sales?


I use CALCULATE(func; FILTER(table; condition)) all the time and I really don't know why it's happenning now. 

Here some date to test:

Customer_NameSale_ValueCustomer_Id
Jonh Doe791.641
Jonh Doe353.642
Finn105.123
Finn112.323
Finn237.843
Jonh Doe394.321
Finn140.63
Finn184.383
Finn375.363
Finn266.43
Finn86.043
Finn155.283
Finn70.263
Finn37.843
Finn53.073
Poe143.454
Poe59.284
Poe129.454
Jonh Doe391.21
Jonh Doe292.81
Jonh Doe328.321
Jonh Doe394.21
Jonh Doe505.021
Jonh Doe35601
Jonh Doe819.21
Jonh Doe68.882
Jonh Doe273.62
Jonh Doe574.82
Jonh Doe10682
Ren3283.25
Ren82505

 

1 ACCEPTED SOLUTION
Iamnvt
Continued Contributor
Continued Contributor

hi,

 

if you show the total for the table, it will appear the result as "5" also.

The reason is for the total value, it consider having no filter on "Customer_ID" column.

Your measure uses SUM('Table'[Sale_Value]), so when no "customer_ID" is selected, the SUM is for the whole "Table" table, which has the value > 1000, so the after-filtered table is kept the same (no filter). With that same table, it has 5 "Customer_ID" in the after-filtered Table.

 

To get the Measure works, you need to change to:

MeasureWithProblem = CALCULATE(DISTINCTCOUNT('Table'[Customer_ID]), FILTER('Table', 'Table'[Sale_Value] >1000))

each Rows in the Table will be evaluated, not the SUM as your previous measure.

View solution in original post

1 REPLY 1
Iamnvt
Continued Contributor
Continued Contributor

hi,

 

if you show the total for the table, it will appear the result as "5" also.

The reason is for the total value, it consider having no filter on "Customer_ID" column.

Your measure uses SUM('Table'[Sale_Value]), so when no "customer_ID" is selected, the SUM is for the whole "Table" table, which has the value > 1000, so the after-filtered table is kept the same (no filter). With that same table, it has 5 "Customer_ID" in the after-filtered Table.

 

To get the Measure works, you need to change to:

MeasureWithProblem = CALCULATE(DISTINCTCOUNT('Table'[Customer_ID]), FILTER('Table', 'Table'[Sale_Value] >1000))

each Rows in the Table will be evaluated, not the SUM as your previous measure.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.