Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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:
ID | Value | ColumnX | Country | Date |
1 | 110 | AAA | SWE | 2024-06-26 |
1 | 120 | AAA | SWE | 2024-06-26 |
1 | 130 | BBB | SWE | 2024-06-26 |
2 | 140 | BBB | SWE | 2024-06-26 |
2 | 100 | AAA | SWE | 2024-06-26 |
3 | 200 | BBB | NOR | 2024-06-26 |
3 | 300 | AAA | NOR | 2024-06-26 |
4 | 123 | AAA | SWE | 2024-06-26 |
1 | 321 | BBB | SWE | 2024-06-26 |
2 | 222 | AAA | SWE | 2024-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.
Solved! Go to Solution.
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:
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.
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.
No filters for that column, but I tried and it didn't help
But thanks for the reply
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:
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.
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...
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
9 |