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
gluizqueiroz
Resolver I
Resolver I

CALCULATE(DISTINCTCOUNT(Values); ALL(Column)) doesn't work as expected

image.png

I made the previous table just for example. 
I have a column name "Month Contract Broken" and I wanna know how much contracts was in each month, for this, I made a simple DISTINCTCOUNT(sale_id) and it is the first column and its nice.
Now, for the column "Expect Result" I made a simple CALCULATE(DISTINCTCOUNT(sales[sale_id]); ALL(sales_instal['Month Contract Broken'])) but it not returns the expect result, returns the same value as "Simple Count".

I don't know where is the problem, I have a lot of tables on my data model and a lot of columns, someone knows what can cause it? 

Month Contract Broken is on a table named "sales_instal" and "sale_id" was on a table named "sales" 

1 ACCEPTED SOLUTION
gluizqueiroz
Resolver I
Resolver I

Finally, I can solve my problem. After tests and tests I realize that my problem was in "Classify Column". 
The column "Month Contract Broken" was classified by another column (Because "1st month", "2nd month" was texts and Power BI ordenate in the following order: 1st month, 10th month, 11th month) and believe it, I need to put on my SIMPLE measure the ALL of column that I used to classify.

Measre Solved = CALCULATE(DISTINCTCOUNT(sales['sale_id']); ALL(sales_instal['Month Contract Broken']; sales_instal['Class_MonthContractBroken']))

And I can say, I don't have the column "Class_MonthContractBroken" on my visual table, just the column "Month Contract Broken" and my measure.

Hey Microsoft, this behavior is expected?

View solution in original post

2 REPLIES 2
gluizqueiroz
Resolver I
Resolver I

Finally, I can solve my problem. After tests and tests I realize that my problem was in "Classify Column". 
The column "Month Contract Broken" was classified by another column (Because "1st month", "2nd month" was texts and Power BI ordenate in the following order: 1st month, 10th month, 11th month) and believe it, I need to put on my SIMPLE measure the ALL of column that I used to classify.

Measre Solved = CALCULATE(DISTINCTCOUNT(sales['sale_id']); ALL(sales_instal['Month Contract Broken']; sales_instal['Class_MonthContractBroken']))

And I can say, I don't have the column "Class_MonthContractBroken" on my visual table, just the column "Month Contract Broken" and my measure.

Hey Microsoft, this behavior is expected?

Hi @gluizqueiroz ,

 

You could try ALL(sales).

Your visuals only show the fields you select. If you need it, you could add it to your visual. "Class_MonthContractBroken" belongs to sales_instal, I think these two tables have a relationship and you could use it in your DAX directly.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

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.