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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Shreeram04
Resolver III
Resolver III

Distinct Row Count

Hi All,

My requirement is to count distinct rows.

 

Sample Data:

 

AreaCountryBrand
A1c1b1
A1c1b1
A1c2b1
A1c2b3
A1c2b3
A1c4b2
A1c3b1
A1c4b5
A1c4b1
A1c5b1
A1c5b2
A2c6b1
A2c7b2
A2c8b3
A2c9b4
A2c10b5
A2c11b6
A2c12b7

 

when I filter A1 in Area and c1,c2 in-country means the brand row count value show as 4. It should take  distinct count for c1(b1,b2) as 2 and c2 for 2(b3,b1) so total as 4.

 

AreaCountryBrand
A1c1b1
A1c1b1
A1c2b1
A1c2b3
A1c2b3
A1c1b2

 

While I am using a distinct Dax measure it takes a total distinct count but wants distinct value based on country.

 

Shreeram04_0-1653644070559.png

Please help me to identify the solution. Thanks in Advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Shreeram04 ,

Here are the steps you can follow:

1. Create measure.

Measure =
var _selectarea=SELECTEDVALUE('Table'[Area])
var _selectcountry=SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[Area]=_selectarea),"1",[Country])
return
CALCULATE(DISTINCTCOUNT('Table'[Brand]),FILTER(ALL('Table'),'Table'[Area]=_selectarea&&'Table'[Country] in _selectcountry))

2. Result:

vyangliumsft_0-1653877392105.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @Shreeram04 ,

Here are the steps you can follow:

1. Create measure.

Measure =
var _selectarea=SELECTEDVALUE('Table'[Area])
var _selectcountry=SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[Area]=_selectarea),"1",[Country])
return
CALCULATE(DISTINCTCOUNT('Table'[Brand]),FILTER(ALL('Table'),'Table'[Area]=_selectarea&&'Table'[Country] in _selectcountry))

2. Result:

vyangliumsft_0-1653877392105.png

 

Best Regards,

Liu Yang

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

"My requirement is to count distinct rows"

 

I don't think that's  what your requirement is.  It sounds more like a "filtering up" pattern where you want to identify other rows outside of the filter context as well. The distinct count for your given example is indeed 3.  But as I understand your expected result is 4 because you want to look beyond the combined filter, right?

 

Filters in DAX are applied together.  

 

Area = A1 and Country in ( c1, c2 )

 

rather than 

 

Area = A1 or Country in ( c1, c2 )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.