Forum Discussion
Unique Count in Row convert
- 6 months ago
Hi Tevon713,
Thank you for the follow-up and for testing the helper-table approach.
The behaviour you are seeing occurs because Power BI measures are always evaluated based on the current filter context, so when a helper table is related back to the fact table, slicers such as Year, Region, or Product still propagate and change the result. This is why the unique count continues to vary (for example 7 instead of 14), even though the logic appears correct.
If your requirement is to count accounts that appear exactly once in the entire dataset and keep that value constant regardless of filters, the uniqueness logic must explicitly ignore report filters. You can achieve this using the following measure, which evaluates uniqueness across the full dataset and removes all filters:Truly Unique Accounts := CALCULATE ( COUNTROWS ( FILTER ( SUMMARIZE ( ALL ( 'Fact' ), 'Fact'[Acct #], "RowCnt", COUNTROWS ( 'Fact' ) ), [RowCnt] = 1 ) ), REMOVEFILTERS ( 'Fact' ) )This measure evaluates uniqueness at the Account # level and will consistently return 14, matching the intent of your original Excel logic, regardless of how the report is filtered.
Thanks again for using the Microsoft Fabric Community Forum.
Still unclear what you want to achieve. But try this:
Test measure =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Acct #] ),
KEEPFILTERS ( 'Table'[Prior Yr Uniq Ct] <> 1 )
)
-- or ISBLANK('Table'[Prior Yr Uniq Ct])
Thanks danextian.
Just a test, if I ignore the prior yr uniq ct column and imported in another month. Using the same logic for excel uniq ct formula = 12 and test measure = 14, difference of 2. How to keep the distinct count measure truly unique regardless of the facts filter?
- danextian7 months agoSuper User
This is unclear. What is your definition of truly unique? Using your sample pbix and with filters applied, what results do you expect adn why?
- Tevon7137 months agoHelper V
Thanks danextian. Count if the acct # is truly unique (appear only once throughout the dataset) and distinct regardless of the date (and other facts). The test measure should match the sum of uniq ct ( ie the orginal excel uniq formula to begin with) -import it in as a test case.
- v-kpoloju-msft6 months agoCommunity Support
Hi Tevon713,
Thank you for reaching out to the Microsoft Fabric Community Forum and thanks for the clarification.
The behaviour you are seeing is expected and comes from a core difference between Excel and Power BI. Your Excel helper column fixes “uniqueness” row-by-row and does not re-evaluate when filters are applied, whereas Power BI measures are always recalculated based on the current filter context (date, region, product, etc.). Because of this, DISTINCTCOUNT will change as you slice the data, which is why your Excel result and the test measure don’t always match.
If your requirement is to count Account #s that appear exactly once in the entire dataset and keep that result stable regardless of filters, the clean approach is to define global uniqueness first. You can do this by creating a small helper table that ignores filters and keeps only accounts with a total row count of 1 (for example, using SUMMARIZE(ALL(Table), Table[Acct #], "Cnt", COUNTROWS(Table)) and filtering where Cnt = 1). Relate this table back to your fact table on Account #, and then use a simple COUNTROWS measure on the helper table. This mirrors the intent of your Excel logic while remaining reliable and scalable in Power BI.
Hope that clarifies. Let us know if you have any doubts regarding this. We will be happy to help.Thank you for using the Microsoft Fabric Community Forum.