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.
Hi,
I'd like to have a dax like distinctcount and countx. discount a table/column with filter.
sample table as below left, I have created a measure m1 (m1 = DISTINCTCOUNT(table1[c1])) and it's able to show in the table visual with a filter of c2. I want to show another column with the measure m2 with all distinctcount(table[c1]) without any filter from c2. I try to create one but got the error message. How can I get it?
Thanks
Solved! Go to Solution.
@yishenhui Try:
m2 = COUNTROWS( DISTINCT( SELECTCOLUMNS( ALL('table1'), "c1", [c1] ) ) )
@yishenhui Try:
m2 =
VAR __c3Table = SELECTECOLUMNS( 'table1', "c3", [c3] )
VAR __Result =
COUNTROWS(
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL('table1'), [c3] IN __c3Table ),
"c1", [c1]
)
)
)
RETURN
__Result
@yishenhui Try:
m2 = COUNTROWS( DISTINCT( SELECTCOLUMNS( ALL('table1'), "c1", [c1] ) ) )
Hi Greg,
It did work. I will accept as solution. I also added another column and some data as below. c3 will be a column in the table visual. The second column shows all counts as before. can I have the DAX that show the distcount with filter c3 but without c2? I tried write another DAX M3 but looks like it cannot see [c3].
@yishenhui Try:
m2 =
VAR __c3Table = SELECTECOLUMNS( 'table1', "c3", [c3] )
VAR __Result =
COUNTROWS(
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL('table1'), [c3] IN __c3Table ),
"c1", [c1]
)
)
)
RETURN
__Result
Hi Greg,
I found another issue. Here assume c3 is always existed in all selection of c2 with is good. But if I change the data a little bit, replaced one "c" to to "b" (hightlighted). Then when I choose the "c" in the slicer, because "c" is nolonger existed with any rows having ca, the result table doesn't have record for ca any more. Is it possible even the selection doesn't exist in that group, the total count still showing. Means in this case, for row ca, m1 will be 0 and m3 will continue show 2?
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 |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
9 |