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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

"ALL" not working properly with sorting table

I'm encountering an error (or whatever I'm doing wrong...) where I have a calculation from fact Table A, for which I have a sorting table, that sorts the column rows into correct order. No problems here. We can call this ColumnX

 

I'm now trying to calculate a measure that should get all rows (per this ColumnX) divided by the total number of unique "SaleID" and then divided by the total number of days within this period. 

So far no worries, this measue works as intended when using the ColumnX from the regular table and I get the expected results. However, when I'm using the sorting column I get the wrong results. 

I've narrowed it down to it being the distinctcount of SaleID that end up wrong. Instead of it giving me the total number, it gives the total number per ColumnX. 

 

Here's my calculations: 

 

var _volume = COUNTROWS(TableA)

var _saleID = CALCULATE(DISTINCTCOUNT(TableA[ID]), ALL(TableA[ColumnX]), ALL(SortTable[ColumnY))

var _days = COUNT('Date'[Date])

var _average = DIVIDE(_volume,_saleID)

RETURN

DIVIDE(_average,_days)

 

For example:

var _saleID = CALCULATE(DISTINCTCOUNT(TableA[ID]), ALL(TableA[ColumnX]), ALL(SortColumn[ColumnY)) gives me the number 195 when using the main table. For all variatns of ColumnX

 

But, when using sort Table

I get 127 and 190

Which leads to the errors in my results. 

 

there's a 1-* relationship with single crossfilter direction between the main table and sorting table

I've tired making this go both ways but didn't help

 

Any idea on how to solve this? 

 

Edit: 

Table with sample data:

IDValueColumnXCountryDate
1110AAASWE2024-06-26
1120AAASWE2024-06-26
1130BBBSWE2024-06-26
2140BBBSWE2024-06-26
2100AAASWE2024-06-26
3200BBBNOR2024-06-26
3300AAANOR2024-06-26
4123AAASWE2024-06-26
1321BBBSWE2024-06-26
2222AAASWE2024-06-26

 

So for the example above: 

There are three unique IDs (1, 2 &4) for Sweden, and a total of 8 rows (for Sweden). 5 AAA rows, and 3 BBB rows. 

 

What I want is to then calculate:

for AAA column:

5/3/1 - 5 is for the five AAA rows, 3 is for three uniqe Sweden IDs, and 1 is for the number of days. 

for BBB column:

3/3/1 - 3 is for the three BBB rows, 3 is for three uniqe Sweden IDs, and 1 is for the number of days. 

 

What actually happens in Power BI is it instead calculates BBB column as:

3/2/1, because it only calculates the unique IDs for BBB columns. Instead of the total Sweden rows. 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

For the counting of individual IDs, you can try the following expression, and if there are still other problems, show your expected results:

vtianyichmsft_0-1720161355296.png

Measure = CALCULATE(DISTINCTCOUNT('Table'[ID]),ALLEXCEPT('Table','Table'[Country]))

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

 

Any filters used? Try replacing ALL with ALLSELECTED.

 

Please feel free to correct me and provide more information if I have misunderstood you!

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

No filters for that column, but I tried and it didn't help

But thanks for the reply

Anonymous
Not applicable

Hi @Anonymous ,

 

For the counting of individual IDs, you can try the following expression, and if there are still other problems, show your expected results:

vtianyichmsft_0-1720161355296.png

Measure = CALCULATE(DISTINCTCOUNT('Table'[ID]),ALLEXCEPT('Table','Table'[Country]))

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Anonymous
Not applicable

@lbendlin 

Thanks!

I updated the original post with some more info and a table

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.