DAX and distinct count filter context help

Guitarmageddon

Board Regular
Joined
Dec 22, 2014
Messages
159
So I have just one table that I added to the data model, to give me some of the flexibility of dax and afford me some practice time. I have a measure that is a distinct count on my "sites" column, to count unique store numbers in my data set. I would like the measure to ignore the filter context though, and no matter what site I may have the pivot table filtered down to, I want it to still reflect ALL my stores and not convert the distinct count to say, 1, once I filter. I think I need an ALL function here, but I cant quite grasp. can anyone give some tips? Currently its just =DISTINCTCOUNT([Site])
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I'd have the DISTINCTCOUNT as a separate measure and do this with two measures:

Measure1 = DISTINCTCOUNT(TableName[Site])

Measure2 = CALCULATE( [Measure1], ALL(TableName))

The two measure approach lets you use the same DISTINCTCOUNT-measure in other calculations as well and it makes the second measure easier to read & adjust when needed.
 
Upvote 0
I'd have the DISTINCTCOUNT as a separate measure and do this with two measures:

Measure1 = DISTINCTCOUNT(TableName[Site])

Measure2 = CALCULATE( [Measure1], ALL(TableName))

The two measure approach lets you use the same DISTINCTCOUNT-measure in other calculations as well and it makes the second measure easier to read & adjust when needed.

Hmm thanks for helping. I did that like you said, however it still is obeying the main filter context of the table. I have "site" dragged into the filters part of my pivot table, and I have it to just one site currently. It only works when I unfilter back to ALL sites, just like the original count distinct acts. Any thoughts?


After some playing with it, I think I wasnt entirely clear with what I needed. I think I wanted to see count of distinct sites, regardless of filter, but within the context of another column called "generation."


=CALCULATE(Table1[DISTINCT SITE COUNT],FILTER(Table1,DISTINCTCOUNT([Gen])))

This one works just like it should, however, it filters back to all "1"s when I but a single site filter on the table. I know this probably is sounding confusing, I can provide a screenshot of the table construction if that would help? Or is what Im trying to do just not possible?
 
Upvote 0

Forum statistics

Threads
1,214,521
Messages
6,120,018
Members
448,937
Latest member
BeerMan23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top